• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EDT 15:52
CET 20:52
KST 04:52
  • Home
  • Forum
  • Calendar
  • Streams
  • Liquipedia
  • Features
  • Store
  • EPT
  • TL+
  • StarCraft 2
  • Brood War
  • Smash
  • Heroes
  • Counter-Strike
  • Overwatch
  • Liquibet
  • Fantasy StarCraft
  • TLPD
  • StarCraft 2
  • Brood War
  • Blogs
Forum Sidebar
Events/Features
News
Featured News
ByuL: The Forgotten Master of ZvT30Behind the Blue - Team Liquid History Book19Clem wins HomeStory Cup 289HomeStory Cup 28 - Info & Preview13Rongyi Cup S3 - Preview & Info8
Community News
BGE Stara Zagora 2026 cancelled7Blizzard Classic Cup - Tastosis announced as captains12Weekly Cups (March 2-8): ByuN overcomes PvT block4GSL CK - New online series18BSL Season 224
StarCraft 2
General
BGE Stara Zagora 2026 cancelled BGE Stara Zagora 2026 announced ByuL: The Forgotten Master of ZvT Terran AddOns placement Blizzard Classic Cup - Tastosis announced as captains
Tourneys
StarCraft Evolution League (SC Evo Biweekly) https://www.facebook.com/BubaSocks.Official/ [GSL CK] Team Maru vs. Team herO WardiTV Team League Season 10 Master Swan Open (Global Bronze-Master 2)
Strategy
Custom Maps
Publishing has been re-enabled! [Feb 24th 2026] Map Editor closed ?
External Content
The PondCast: SC2 News & Results Mutation # 516 Specter of Death Mutation # 515 Together Forever Mutation # 514 Ulnar New Year
Brood War
General
ASL21 General Discussion BGH Auto Balance -> http://bghmmr.eu/ BW General Discussion Gypsy to Korea Are you ready for ASL 21? Hype VIDEO
Tourneys
[Megathread] Daily Proleagues [BSL22] Open Qualifiers & Ladder Tours IPSL Spring 2026 is here! ASL Season 21 Qualifiers March 7-8
Strategy
Simple Questions, Simple Answers Soma's 9 hatch build from ASL Game 2 Fighting Spirit mining rates Zealot bombing is no longer popular?
Other Games
General Games
Stormgate/Frost Giant Megathread Path of Exile Nintendo Switch Thread PC Games Sales Thread No Man's Sky (PS4 and PC)
Dota 2
Official 'what is Dota anymore' discussion The Story of Wings Gaming
League of Legends
Heroes of the Storm
Simple Questions, Simple Answers Heroes of the Storm 2.0
Hearthstone
Deck construction bug Heroes of StarCraft mini-set
TL Mafia
Five o'clock TL Mafia Mafia Game Mode Feedback/Ideas Vanilla Mini Mafia TL Mafia Community Thread
Community
General
US Politics Mega-thread Things Aren’t Peaceful in Palestine Russo-Ukrainian War Thread Mexico's Drug War NASA and the Private Sector
Fan Clubs
The IdrA Fan Club
Media & Entertainment
Movie Discussion! [Req][Books] Good Fantasy/SciFi books [Manga] One Piece
Sports
Formula 1 Discussion 2024 - 2026 Football Thread General nutrition recommendations Cricket [SPORT] TL MMA Pick'em Pool 2013
World Cup 2022
Tech Support
Laptop capable of using Photoshop Lightroom?
TL Community
The Automated Ban List
Blogs
Iranian anarchists: organize…
XenOsky
FS++
Kraekkling
Shocked by a laser…
Spydermine0240
Gaming-Related Deaths
TrAiDoS
Unintentional protectionism…
Uldridge
ASL S21 English Commentary…
namkraft
Customize Sidebar...

Website Feedback

Closed Threads



Active: 2646 users

The Big Programming Thread - Page 598

Forum Index > General Forum
Post a Reply
Prev 1 596 597 598 599 600 1032 Next
Thread Rules
1. This is not a "do my homework for me" thread. If you have specific questions, ask, but don't post an assignment or homework problem and expect an exact solution.
2. No recruiting for your cockamamie projects (you won't replace facebook with 3 dudes you found on the internet and $20)
3. If you can't articulate why a language is bad, don't start slinging shit about it. Just remember that nothing is worse than making CSS IE6 compatible.
4. Use [code] tags to format code blocks.
Arnstein
Profile Blog Joined May 2010
Norway3381 Posts
March 02 2015 12:11 GMT
#11941
What's the most stable operative system? No ProblemOS.


...I'll show myself out.
rsol in response to the dragoon voice being heard in SCII: dragoon ai reaches new lows: wanders into wrong game
Blisse
Profile Blog Joined July 2010
Canada3710 Posts
March 02 2015 12:15 GMT
#11942
On March 02 2015 20:47 Manit0u wrote:
Well, the length variable is deceiving in this case because if length = 12 the generated password will have 16 characters...


excellent time to use --I vs I-- here!
There is no one like you in the universe.
Gowerly
Profile Blog Joined July 2011
United Kingdom916 Posts
Last Edited: 2015-03-02 12:18:02
March 02 2015 12:17 GMT
#11943
"*this" will try to dereference the this pointer. You don't want that, if you're accepting pointers into the addObjectToList function
Also, you probably want

class character
{
public:
character();
}


Also

addObjectToList(character *obj)
{
objectList.push_back(obj);
}

as you don't qualify the items that you are pushing into your list (as the list is a vector of characters anyway).
I will reduce you to a series of numbers.
Manit0u
Profile Blog Joined August 2004
Poland17692 Posts
Last Edited: 2015-03-02 12:25:19
March 02 2015 12:18 GMT
#11944
On March 02 2015 21:15 Blisse wrote:
Show nested quote +
On March 02 2015 20:47 Manit0u wrote:
Well, the length variable is deceiving in this case because if length = 12 the generated password will have 16 characters...


excellent time to use --I vs I-- here!


Nono, post-decrement is exactly what I needed. What had to be changed was:


$i = abs($length / 3); >>> $i = abs(intval($length / 4));


It seems that at some previous point the method was only generating 3 characters per iteration. It was later changed to generate 4 characters but someone forgot to change the number of iterations. Took me a while to get a hold of person who wrote it in the first place and get him to recall how and why did he did it this way...

I've also made it convert division to integer since abs can be float and it could get silly (as in endless loop blowing out the stack) if someone wanted to generate an odd-length password.
Time is precious. Waste it wisely.
Blisse
Profile Blog Joined July 2010
Canada3710 Posts
Last Edited: 2015-03-02 12:29:24
March 02 2015 12:26 GMT
#11945
On March 02 2015 21:18 Manit0u wrote:
Show nested quote +
On March 02 2015 21:15 Blisse wrote:
On March 02 2015 20:47 Manit0u wrote:
Well, the length variable is deceiving in this case because if length = 12 the generated password will have 16 characters...


excellent time to use --I vs I-- here!


Nono, post-decrement is exactly what I needed. What had to be changed was:


$i = abs($length / 3); >>> $i = abs(intval($length / 4));


It seems that at some previous point the method was only generating 3 characters per iteration. It was later changed to generate 4 characters but someone forgot to change the number of iterations. Took me a while to get a hold of person who wrote it in the first place and get him to recall how and why did he did it this way...

I've also made it convert division to integer since abs can be float and it could get silly (as in endless loop blowing out the stack) if someone wanted to generate an odd-length password.


whoops I was too excited to apply our new knowledge of post and pre increment decrement operators!

4 is right, 3 is wrong o:

I feel like there's a much better way of doing this though lol
There is no one like you in the universe.
Manit0u
Profile Blog Joined August 2004
Poland17692 Posts
Last Edited: 2015-03-02 13:51:41
March 02 2015 13:50 GMT
#11946
On March 02 2015 21:26 Blisse wrote:
Show nested quote +
On March 02 2015 21:18 Manit0u wrote:
On March 02 2015 21:15 Blisse wrote:
On March 02 2015 20:47 Manit0u wrote:
Well, the length variable is deceiving in this case because if length = 12 the generated password will have 16 characters...


excellent time to use --I vs I-- here!


Nono, post-decrement is exactly what I needed. What had to be changed was:


$i = abs($length / 3); >>> $i = abs(intval($length / 4));


It seems that at some previous point the method was only generating 3 characters per iteration. It was later changed to generate 4 characters but someone forgot to change the number of iterations. Took me a while to get a hold of person who wrote it in the first place and get him to recall how and why did he did it this way...

I've also made it convert division to integer since abs can be float and it could get silly (as in endless loop blowing out the stack) if someone wanted to generate an odd-length password.


whoops I was too excited to apply our new knowledge of post and pre increment decrement operators!

4 is right, 3 is wrong o:

I feel like there's a much better way of doing this though lol


Yeah, but this isn't my priority. Just "boyscouted" it while fixing something else entirely

I still couldn't stand it and now this method looks like that (and returns proper length):


protected function generatePassword($length = 12)
{
$lowercaseLettersArray = range('a', 'z');
$uppercaseLettersArray = range('A', 'Z');
$numbersArray = range(0, 9);
$specialCharactersArray = array('_', '!', '?');
$randomizedString = '';

$randomizedString .= $this->getRandomCharacterPairFromArrays($numbersArray, $specialCharactersArray);

$i = abs(intval(($length - 2) / 2));

while ($i--) {
$randomizedString .= $this->getRandomCharacterPairFromArrays($lowercaseLettersArray, $uppercaseLettersArray);
}

return str_shuffle($randomizedString);
}

protected function getRandomArrayMember($array)
{
return $array[array_rand($array)];
}

protected function getRandomCharacterPairFromArrays($firstArray, $secondArray)
{
$characterPair = '';

$characterPair .= $this->getRandomArrayMember($firstArray);
$characterPair .= $this->getRandomArrayMember($secondArray);

return $characterPair;
}
Time is precious. Waste it wisely.
iaretehnoob
Profile Joined June 2004
Sweden741 Posts
March 02 2015 13:55 GMT
#11947
On March 02 2015 22:50 Manit0u wrote:
Show nested quote +
On March 02 2015 21:26 Blisse wrote:
On March 02 2015 21:18 Manit0u wrote:
On March 02 2015 21:15 Blisse wrote:
On March 02 2015 20:47 Manit0u wrote:
Well, the length variable is deceiving in this case because if length = 12 the generated password will have 16 characters...


excellent time to use --I vs I-- here!


Nono, post-decrement is exactly what I needed. What had to be changed was:


$i = abs($length / 3); >>> $i = abs(intval($length / 4));


It seems that at some previous point the method was only generating 3 characters per iteration. It was later changed to generate 4 characters but someone forgot to change the number of iterations. Took me a while to get a hold of person who wrote it in the first place and get him to recall how and why did he did it this way...

I've also made it convert division to integer since abs can be float and it could get silly (as in endless loop blowing out the stack) if someone wanted to generate an odd-length password.


whoops I was too excited to apply our new knowledge of post and pre increment decrement operators!

4 is right, 3 is wrong o:

I feel like there's a much better way of doing this though lol


Yeah, but this isn't my priority. Just "boyscouted" it while fixing something else entirely

I still couldn't stand it and now this method looks like that (and returns proper length):

What if someone wants an odd-length password?
Manit0u
Profile Blog Joined August 2004
Poland17692 Posts
Last Edited: 2015-03-02 14:37:47
March 02 2015 14:37 GMT
#11948
On March 02 2015 22:55 iaretehnoob wrote:
Show nested quote +
On March 02 2015 22:50 Manit0u wrote:
On March 02 2015 21:26 Blisse wrote:
On March 02 2015 21:18 Manit0u wrote:
On March 02 2015 21:15 Blisse wrote:
On March 02 2015 20:47 Manit0u wrote:
Well, the length variable is deceiving in this case because if length = 12 the generated password will have 16 characters...


excellent time to use --I vs I-- here!


Nono, post-decrement is exactly what I needed. What had to be changed was:


$i = abs($length / 3); >>> $i = abs(intval($length / 4));


It seems that at some previous point the method was only generating 3 characters per iteration. It was later changed to generate 4 characters but someone forgot to change the number of iterations. Took me a while to get a hold of person who wrote it in the first place and get him to recall how and why did he did it this way...

I've also made it convert division to integer since abs can be float and it could get silly (as in endless loop blowing out the stack) if someone wanted to generate an odd-length password.


whoops I was too excited to apply our new knowledge of post and pre increment decrement operators!

4 is right, 3 is wrong o:

I feel like there's a much better way of doing this though lol


Yeah, but this isn't my priority. Just "boyscouted" it while fixing something else entirely

I still couldn't stand it and now this method looks like that (and returns proper length):

What if someone wants an odd-length password?


He'll get a password one character shorter. Not my problem really, I only made the code easier to understand, a bit more efficient (one loop instead of four), a bit more elegant, a bit more in line with what was originally intended and a bit safer (no more floats in loop conditions). Wasn't my job to create the algorithm or update it.
Time is precious. Waste it wisely.
sabas123
Profile Blog Joined December 2010
Netherlands3122 Posts
Last Edited: 2015-03-02 21:04:06
March 02 2015 19:15 GMT
#11949
edit: im just an idiot.

here is a good blog about game programming for the people who missed it.
http://www.teamliquid.net/forum/general/382368-game-programming-primer#h.z3ke7fjrib1n
The harder it becomes, the more you should focus on the basics.
netherh
Profile Blog Joined November 2011
United Kingdom333 Posts
March 02 2015 23:11 GMT
#11950
On March 03 2015 04:15 sabas123 wrote:
I recently saw a few posts on gamedev about entity based architecture in c++.

I was wondering how I could make a custom component and then attach it to my entity. I would assume that the base enitity would just be a long int

ref: http://gamedev.stackexchange.com/questions/31473/role-of-systems-in-entity-systems-architecture/31491#31491


I don't think that post actually describes the ideas involved in an entity system at all. It just describes one very specific approach. (What follows is a segue into my own theories, and may not be relevant / helpful, sorry about that). >.>

I think the whole thing comes down to balancing lookup, iteration and sorting.

If you use the heap for entities and (more importantly) components, you automatically get persistent handles (pointers!) that you can use for the lifetime of the object, and no lookup cost. This is really, really nice. It's something you shouldn't give up unless you have a really good reason.

The downside of this is that it might be slow if you want to iterate over a whole bunch of the same component type: you're jumping all over the place in memory. However, this isn't an issue 99.99% of the time. The solution to this problem is to store your objects in contiguous memory (i.e. a vector / array). Your choices then become (from some notes I made a while ago):


// Plain array
// Fast creation / deletion
// Fast iteration
// Can't do lookup and / or sorting without additional hassle.

// Possible lookup types:

// Intrusive ID
// Fast iteration - (slightly slower than plain array)
// Slow lookup - O(n)
// Fast sorting.

// ID + index map
// Fast lookup - O(log(n)) or O(1) ?
// Requires custom sorting code.
// Very slow sorting - updating indices during swap :(

// ID + index list
// Fast lookup - O(1)
// Requires custom sorting code.
// Very slow sorting - updating indices during swap :(


Of these, the intrusive ID version is probably the best, but still: If speed is really an issue (it isn't), you're almost certainly better off refactoring the offending components into pure data stored in an appropriate aggregate component, rather than changing the component system itself.

So here's a bunch of pseudo-code with what I'd basically do:



class Component
{
public:

virtual void Connect(GameObject& object) = 0;
virtual void Disconnect() = 0;

virtual std::type_index GetType() const = 0;
};

class FooComponent final : public Component
{
public:

void Connect(GameObject& object)
{
// get other components from object if necessary...

// attach to relevant systems:
Service<FooSystem>::Get().AddComponent(this);
}

void Disconnect()
{
Service<FooSystem>::Get().RemoveComponent(this);
}

std::type_index GetType() const
{
return std::type_index(typeid(FooComponent));
}
};

class FooSystem
{
public:

void AddComponent(FooComponent* component);
void RemoveComponent(FooComponent* component);

private:

std::vector<FooComponent*> components;
};

class GameObject
{
public:

GameObject():
connected(false) { }

~GameObject()
{
Disconnect();
}

GameObject(GameObject const& other) = delete;
GameObject& operator=(GameObject const& other) = delete;

// You can add a move constructor / move assignment if you wish.
// Just don't store pointers to GameObjects if you do.


template<class T, class... Args>
T* AddComponent(Args&&... args)
{
// create component
// add to vector

// if object is connected
connect this component

// return component
}

template<class T>
bool HasComponent() const
{
for (auto const& c : components)
if (c->GetType() == std::type_index(typeid(T)))
return true;

return false;
}

template<class T>
T* GetFirstComponent();

template<class T>
std::vector<T*> GetAllComponents();

template<class T>
void RemoveFirstComponent();

template<class T>
void RemoveAllComponents();

void ClearComponents();


void Connect()
{
if (connected)
return;

for (auto& c : components)
c->Connect(*this);

connected = true;
}

void Disconnect()
{
if (!connected)
return;

for (auto& c : components)
c->Disconnect();

connected = false;
}

private:

bool connected;
std::vector<std::unique_ptr<Component>> components;
};

// So then:

auto player = GameObject();

player.AddComponent<PlayerController>();
player.AddComponent<ShipRenderable>();

auto collider = SphereCollider(10.f, 1.f);
auto physics = player.AddComponent<PhysicsComponent>(collider);
physics->SetRestitution(0.5f);
physics->SetLinearVelocity(Vector3(0.f, 0.f, -1.f));

player.Connect();

// And everything will be neatly removed / destroyed when the player object goes out of scope!
// You can store the object itself in a unique_ptr, or whatever you need!



The type_index stuff is kind of a pain. You could restrict your objects to only one component of each type, but I don't think it's really necessary. You could perhaps also store components in a map or multi map, and remove the need for the GetType function.


The main thing I see wrong with the post you linked at the start is that at some point you're going to want to write actual gameplay logic. For example... "an object has collided with this one -> check if it's the player, if so play an explosion sound, damage the player, apply a force to push them away". This requires access to a whole bunch of components or systems. That article says that components are basically just data, and can't interact at all, implying that you'll have to create a new system for almost everything.

The components are also so fine grained (separate position and velocity!!) that I suspect you'll quickly become mired in a mess of combination problems and inter-dependencies masked by putting everything in yet another system.


But anyway... to answer your question:

I have no idea! I thought about it for a bit. I imagine you'd want an enum with all your bitmasks e.g.:


enum ComponentTypes
{
PhysicsComponent = 1u << 0u,
PlayerComponent = 1u << 1u,
ShipComponent = 1u << 2u,
// etc.
};


The entity could then contain a long unsigned , and you could do something like "entityMask |= PhysicsComponent;" when you add a component.

But that's going to be a pain in the arse to maintain. You're also probably going to want each component type to have a GetType() function (similar to my own example) that returns the relevant mask type. This is already more irritating to maintain than my example above. You could try some weird automatic type registration, but that's waaay more complicated.

Then you have the problem of where you store components. You'll end up doing basically what I did above, anyway. I don't see what you gain from systems looking for relevant components, apart from more complication.

TLDR; Go back to that article, and tell the author to show some code or GTFO (but perhaps more politely).
Vorenius
Profile Blog Joined December 2010
Denmark1979 Posts
Last Edited: 2015-03-03 00:20:55
March 03 2015 00:17 GMT
#11951
I've been doing some nooby c-programming and I can't quite wrap my head around this piece of code. Or rather I thought I could but the result doesn't really match my expectations.

I have a linked list based stack that I push and pop a bunch of numbers to, but the requirements then asks that they are printed out in the order they are added. So I googled for a function to reverse it found this here.

void stack_reverse(struct node **top, struct node **top_next)
{
if(*top == NULL)
{
return;
}
if(*top_next != NULL)
{
temp = (*top_next)->ptr;
(*top_next)->ptr = (*top);
*top = *top_next;
*top_next = temp;
stack_reverse(top,top_next);
}
}


No here's what I would think happens (excuse my paint):
+ Show Spoiler [before] +
[image loading]

+ Show Spoiler [What I would think would happen] +
[image loading]
2,3,4 ptrs are swapped and top points to 4.

+ Show Spoiler [what actually happens] +
[image loading]

So basicly (*top_next)->ptr = (*top); makes the pointer point "in the other direction" (if that makes sense), but I can't see how the previous top (that becomes the bottom) is set to null. But when I run my code, that's what seem to happen.

So basicly it IS working but I thought it shouldn't. For instance this loop where I print the stack out terminates, so at some point it does reach a null pointer:

while (top1 != NULL)
{
write_int(top1->info);
top1 = top1->ptr;
if (top1 != NULL)
{
write_char(',');
}
}


Can someone explain how the '1'node->ptr gets set to null?
Blitzkrieg0
Profile Blog Joined August 2010
United States13132 Posts
Last Edited: 2015-03-03 00:31:13
March 03 2015 00:30 GMT
#11952
The last node in the list has a pointer to null. This null is saved in the temp variable passed through the entire list until the end where the function returns so the recursion ends.

If the function ended up like "what you think" then you wouldn't be able to tell when the list ends and you'd have an infinite loop.
I'll always be your shadow and veil your eyes from states of ain soph aur.
Blisse
Profile Blog Joined July 2010
Canada3710 Posts
Last Edited: 2015-03-03 01:16:16
March 03 2015 00:56 GMT
#11953
Tips for C data structures and methods..

Don't re-use temporary variables
Zero out pointers everytime a variable is initialized
Name things well
Reuse small pieces of code that are 100% guaranteed to work
Avoid recursion if possible
If your code isn't easily readable it'll probably have a bug
If your algorithm is complex and not concise it'll probably have a bug
There is no one like you in the universe.
Khalum
Profile Joined September 2010
Austria831 Posts
Last Edited: 2015-03-03 01:36:09
March 03 2015 01:32 GMT
#11954
If you want to print the stack "in order" without modifying the data you might as well do something like this:


bool print( struct node *element )
{
if ( element == NULL )
return false;

if ( print( element->ptr ) )
write_char( ',' );

write_int( element->info );
return true;
}

BByte
Profile Joined August 2011
Finland49 Posts
March 03 2015 06:48 GMT
#11955
On March 03 2015 09:56 Blisse wrote:
Tips for C data structures and methods..

Don't re-use temporary variables
Zero out pointers everytime a variable is initialized
Name things well
Reuse small pieces of code that are 100% guaranteed to work
Avoid recursion if possible
If your code isn't easily readable it'll probably have a bug
If your algorithm is complex and not concise it'll probably have a bug


These are excellent tips for pretty much any language.

Of course not every language has pointers, and extensive recursion use is fine in some languages, but the other points stand for every programming environment I can think of.
Blisse
Profile Blog Joined July 2010
Canada3710 Posts
March 03 2015 08:16 GMT
#11956
I find those ideas are especially important when playing around with fundamental structures in C/C++ specifically. In lots of languages and problems, you can kind of get away with poor syntax or poor algorithm construction. But when we're talking about implementing a stack in C, or deleting a node from a binary tree, and other basic fundamentals, those are the small, super important lessons I've learned from coding and failing a lot :3 just because C forces you to be so much more explicit that if you're too lax or even overly specific you'll cause an insignificant number of problems (not helped by the compiler...) meanwhile other languages have enough abstractions to cover your ass :p
There is no one like you in the universe.
Manit0u
Profile Blog Joined August 2004
Poland17692 Posts
March 03 2015 08:59 GMT
#11957
On March 02 2015 22:55 iaretehnoob wrote:
Show nested quote +
On March 02 2015 22:50 Manit0u wrote:
On March 02 2015 21:26 Blisse wrote:
On March 02 2015 21:18 Manit0u wrote:
On March 02 2015 21:15 Blisse wrote:
On March 02 2015 20:47 Manit0u wrote:
Well, the length variable is deceiving in this case because if length = 12 the generated password will have 16 characters...


excellent time to use --I vs I-- here!


Nono, post-decrement is exactly what I needed. What had to be changed was:


$i = abs($length / 3); >>> $i = abs(intval($length / 4));


It seems that at some previous point the method was only generating 3 characters per iteration. It was later changed to generate 4 characters but someone forgot to change the number of iterations. Took me a while to get a hold of person who wrote it in the first place and get him to recall how and why did he did it this way...

I've also made it convert division to integer since abs can be float and it could get silly (as in endless loop blowing out the stack) if someone wanted to generate an odd-length password.


whoops I was too excited to apply our new knowledge of post and pre increment decrement operators!

4 is right, 3 is wrong o:

I feel like there's a much better way of doing this though lol


Yeah, but this isn't my priority. Just "boyscouted" it while fixing something else entirely

I still couldn't stand it and now this method looks like that (and returns proper length):

What if someone wants an odd-length password?


I just couldn't let it go...


class PasswordGenerator
{
public function generatePassword($length = 12)
{
$randomizedString = $this->getRequiredPasswordCharacters();

$i = max($length - 4, 4);

while ($i--) {
$randomizedString .= $this->getRandomPasswordCharacter();
}

return str_shuffle($randomizedString);
}

protected function getRandomArrayMember($array)
{
return $array[array_rand($array)];
}

protected function getRequiredPasswordCharacters()
{
return $this->getRandomArrayMember(range('a', 'z'))
. $this->getRandomArrayMember(range('A', 'Z'))
. $this->getRandomArrayMember(range(0, 9))
. $this->getRandomArrayMember(array('_', '!', '?'));
}

protected function getRandomPasswordCharacter()
{
$allowedCharacters = $this->getRequiredPasswordCharacters();

return $allowedCharacters[rand(0, strlen($allowedCharacters) - 1)];
}
}
Time is precious. Waste it wisely.
Nesserev
Profile Blog Joined January 2011
Belgium2760 Posts
March 03 2015 12:15 GMT
#11958
--- Nuked ---
sabas123
Profile Blog Joined December 2010
Netherlands3122 Posts
March 03 2015 12:30 GMT
#11959
On March 03 2015 08:11 netherh wrote:
Show nested quote +
On March 03 2015 04:15 sabas123 wrote:
I recently saw a few posts on gamedev about entity based architecture in c++.

I was wondering how I could make a custom component and then attach it to my entity. I would assume that the base enitity would just be a long int

ref: http://gamedev.stackexchange.com/questions/31473/role-of-systems-in-entity-systems-architecture/31491#31491



template<class T, class... Args>
T* AddComponent(Args&&... args)
{
// create component
// add to vector

// if object is connected
connect this component

// return component
}



this would be something like?

template<class T, class... Args>
T* AddComponent(Args&&... args)
{
FooComponent.connect(this);
components.push_back(FooComponent);
connect();
}

where <class T, class args> would be the class I want to add and the argument so of the constructor of that class?
The harder it becomes, the more you should focus on the basics.
FFGenerations
Profile Blog Joined April 2011
7088 Posts
Last Edited: 2015-03-03 18:09:46
March 03 2015 18:07 GMT
#11960
hey boys, maybe you could give me a pointer here.... the tough part isnt really "finding out what to do" after all.....if you look at enough examples you get the general picture eventually.... but the tough part is finding out how to do it coz it seems like no one does stuff "exactly" how i want to do it and guessing how to do stuff is pretty stupid lol.....you can spend 5 hours trying to guess something and then just ragequit it and have wasted the whole day for no reason whatsoeever.

anyway , again i am trying to receive a response from a 3rd party API, put the response into an object , then print the object to screen so i can verify it (actually you can verify using breakline i bet but again thats fucking around for ages hoping something works and not getting anywhere)

so this is what i have so far, and i have 1 (maybe) missing line that might make it work ......fingers crossed...



Ann.java class that stores the xml data received from the 3rd party api. this was generated by using JAXB wizard on XSD scheme of a sample XML (2500 lines long ...i just paste some of it coz it wont let me paste 2500 lines lol)

+ Show Spoiler [(super long + truncated)] +

// Generated on: 2015.03.03 at 05:12:35 PM GMT
//


package generated;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import javax.xml.bind.JAXBElement;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementRef;
import javax.xml.bind.annotation.XmlMixed;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlSchemaType;
import javax.xml.bind.annotation.XmlType;
import javax.xml.bind.annotation.XmlValue;
import javax.xml.datatype.XMLGregorianCalendar;


/**
* <p>Java class for anonymous complex type.
*
* <p>The following schema fragment specifies the expected content contained within this class.
*
* <pre>
* &lt;complexType>
* &lt;complexContent>
* &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* &lt;sequence>
* &lt;element name="anime">
* &lt;complexType>
* &lt;complexContent>
* &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* &lt;sequence>
* &lt;element name="info" maxOccurs="unbounded" minOccurs="0">
* &lt;complexType>
* &lt;complexContent>
* &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* &lt;sequence>
* &lt;element name="img" minOccurs="0">
* &lt;complexType>
* &lt;simpleContent>
* &lt;extension base="&lt;http://www.w3.org/2001/XMLSchema>string">
* &lt;attribute name="src" type="{http://www.w3.org/2001/XMLSchema}anyURI" />
* &lt;attribute name="width" type="{http://www.w3.org/2001/XMLSchema}short" />
* &lt;attribute name="height" type="{http://www.w3.org/2001/XMLSchema}short" />
* &lt;/extension>
* &lt;/simpleContent>
* &lt;/complexType>
* &lt;/element>
* &lt;/sequence>
* &lt;attribute name="gid" type="{http://www.w3.org/2001/XMLSchema}long" />
* &lt;attribute name="type" type="{http://www.w3.org/2001/XMLSchema}string" />
* &lt;attribute name="src" type="{http://www.w3.org/2001/XMLSchema}anyURI" />
* &lt;attribute name="width" type="{http://www.w3.org/2001/XMLSchema}short" />
* &lt;attribute name="height" type="{http://www.w3.org/2001/XMLSchema}short" />
* &lt;attribute name="lang" type="{http://www.w3.org/2001/XMLSchema}string" />
* &lt;attribute name="href" type="{http://www.w3.org/2001/XMLSchema}anyURI" />
* &lt;/restriction>
* &lt;/complexContent>
* &lt;/complexType>
* &lt;/element>
* &lt;element name="ratings">
* &lt;complexType>
* &lt;simpleContent>
* &lt;extension base="&lt;http://www.w3.org/2001/XMLSchema>string">
* &lt;attribute name="nb_votes" type="{http://www.w3.org/2001/XMLSchema}short" />
* &lt;attribute name="weighted_score" type="{http://www.w3.org/2001/XMLSchema}float" />
* &lt;attribute name="bayesian_score" type="{http://www.w3.org/2001/XMLSchema}float" />
* &lt;/extension>
* &lt;/simpleContent>
* &lt;/complexType>
* &lt;/element>
* &lt;element name="episode" maxOccurs="unbounded" minOccurs="0">
* &lt;complexType>
* &lt;complexContent>
* &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* &lt;sequence>
* &lt;element name="title">
* &lt;complexType>
* &lt;simpleContent>
* &lt;extension base="&lt;http://www.w3.org/2001/XMLSchema>string">
* &lt;attribute name="gid" type="{http://www.w3.org/2001/XMLSchema}long" />
* &lt;attribute name="lang" type="{http://www.w3.org/2001/XMLSchema}string" />
* &lt;/extension>
* &lt;/simpleContent>
* &lt;/complexType>
* &lt;/element>
* &lt;/sequence>
* &lt;attribute name="num" type="{http://www.w3.org/2001/XMLSchema}byte" />
* &lt;/restriction>
* &lt;/complexContent>
* &lt;/complexType>
* &lt;/element>
* &lt;element name="review" maxOccurs="unbounded" minOccurs="0">
* &lt;complexType>
* &lt;simpleContent>
* &lt;extension base="&lt;http://www.w3.org/2001/XMLSchema>string">
* &lt;attribute name="href" type="{http://www.w3.org/2001/XMLSchema}anyURI" />
* &lt;/extension>
* &lt;/simpleContent>
* &lt;/complexType>
* &lt;/element>
* &lt;element name="release" maxOccurs="unbounded" minOccurs="0">
* &lt;complexType>
* &lt;simpleContent>
* &lt;extension base="&lt;http://www.w3.org/2001/XMLSchema>string">
* &lt;attribute name="date" type="{http://www.w3.org/2001/XMLSchema}date" />
* &lt;attribute name="href" type="{http://www.w3.org/2001/XMLSchema}anyURI" />
* &lt;/extension>
* &lt;/simpleContent>
* &lt;/complexType>
* &lt;/element>
* &lt;element name="news" maxOccurs="unbounded" minOccurs="0">
* &lt;complexType>
* &lt;simpleContent>
* &lt;extension base="&lt;http://www.w3.org/2001/XMLSchema>string">
* &lt;attribute name="datetime" type="{http://www.w3.org/2001/XMLSchema}dateTime" />
* &lt;attribute name="href" type="{http://www.w3.org/2001/XMLSchema}anyURI" />
* &lt;/extension>
* &lt;/simpleContent>
* &lt;/complexType>
* &lt;/element>
* &lt;element name="staff" maxOccurs="unbounded" minOccurs="0">
* &lt;complexType>
* &lt;complexContent>
* &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* &lt;sequence>
* &lt;element name="task" type="{http://www.w3.org/2001/XMLSchema}string"/>
* &lt;element name="person">
* &lt;complexType>
* &lt;simpleContent>
* &lt;extension base="&lt;http://www.w3.org/2001/XMLSchema>string">
* &lt;attribute name="id" type="{http://www.w3.org/2001/XMLSchema}int" />
* &lt;/extension>
* &lt;/simpleContent>
* &lt;/complexType>
* &lt;/element>
* &lt;/sequence>
* &lt;attribute name="gid" type="{http://www.w3.org/2001/XMLSchema}long" />
* &lt;/restriction>
* &lt;/complexContent>
* &lt;/complexType>
* &lt;/element>
* &lt;element name="cast" maxOccurs="unbounded" minOccurs="0">
* &lt;complexType>
* &lt;complexContent>
* &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* &lt;sequence>
* &lt;element name="role" type="{http://www.w3.org/2001/XMLSchema}string"/>
* &lt;element name="person">
* &lt;complexType>
* &lt;simpleContent>
* &lt;extension base="&lt;http://www.w3.org/2001/XMLSchema>string">
* &lt;attribute name="id" type="{http://www.w3.org/2001/XMLSchema}int" />
* &lt;/extension>
* &lt;/simpleContent>
* &lt;/complexType>
* &lt;/element>
* &lt;/sequence>
* &lt;attribute name="gid" type="{http://www.w3.org/2001/XMLSchema}long" />
* &lt;attribute name="lang" type="{http://www.w3.org/2001/XMLSchema}string" />
* &lt;/restriction>
* &lt;/complexContent>
* &lt;/complexType>
* &lt;/element>
* &lt;element name="credit" maxOccurs="unbounded" minOccurs="0">
* &lt;complexType>
* &lt;complexContent>
* &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* &lt;sequence>
* &lt;element name="task" type="{http://www.w3.org/2001/XMLSchema}string"/>
* &lt;element name="company">
* &lt;complexType>
* &lt;simpleContent>
* &lt;extension base="&lt;http://www.w3.org/2001/XMLSchema>string">
* &lt;attribute name="id" type="{http://www.w3.org/2001/XMLSchema}short" />
* &lt;/extension>
* &lt;/simpleContent>
* &lt;/complexType>
* &lt;/element>
* &lt;/sequence>
* &lt;attribute name="gid" type="{http://www.w3.org/2001/XMLSchema}long" />
* &lt;/restriction>
* &lt;/complexContent>
* &lt;/complexType>
* &lt;/element>
* &lt;/sequence>
* &lt;attribute name="id" type="{http://www.w3.org/2001/XMLSchema}short" />
* &lt;attribute name="gid" type="{http://www.w3.org/2001/XMLSchema}int" />
* &lt;attribute name="type" type="{http://www.w3.org/2001/XMLSchema}string" />
* &lt;attribute name="name" type="{http://www.w3.org/2001/XMLSchema}string" />
* &lt;attribute name="precision" type="{http://www.w3.org/2001/XMLSchema}string" />
* &lt;attribute name="generated-on" type="{http://www.w3.org/2001/XMLSchema}dateTime" />
* &lt;/restriction>
* &lt;/complexContent>
* &lt;/complexType>
* &lt;/element>
* &lt;/sequence>
* &lt;/restriction>
* &lt;/complexContent>
* &lt;/complexType>
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
"anime"
})
@XmlRootElement(name = "ann")
public class Ann {

@XmlElement(required = true)
protected Ann.Anime anime;

/**
* Gets the value of the anime property.
*
* @return
* possible object is
* {@link Ann.Anime }
*
*/
public Ann.Anime getAnime() {
return anime;
}

/**
* Sets the value of the anime property.
*
* @param value
* allowed object is
* {@link Ann.Anime }
*
*/
public void setAnime(Ann.Anime value) {
this.anime = value;
}


/**
* <p>Java class for anonymous complex type.
*
* <p>The following schema fragment specifies the expected content contained within this class.
*
* <pre>
* &lt;complexType>
* &lt;complexContent>
* &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* &lt;sequence>
* &lt;element name="info" maxOccurs="unbounded" minOccurs="0">
* &lt;complexType>
* &lt;complexContent>
* &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* &lt;sequence>
* &lt;element name="img" minOccurs="0">
* &lt;complexType>
* &lt;simpleContent>
* &lt;extension base="&lt;http://www.w3.org/2001/XMLSchema>string">
* &lt;attribute name="src" type="{http://www.w3.org/2001/XMLSchema}anyURI" />
* &lt;attribute name="width" type="{http://www.w3.org/2001/XMLSchema}short" />
* &lt;attribute name="height" type="{http://www.w3.org/2001/XMLSchema}short" />
* &lt;/extension>
* &lt;/simpleContent>
* &lt;/complexType>
* &lt;/element>
* &lt;/sequence>
* &lt;attribute name="gid" type="{http://www.w3.org/2001/XMLSchema}long" />
* &lt;attribute name="type" type="{http://www.w3.org/2001/XMLSchema}string" />
* &lt;attribute name="src" type="{http://www.w3.org/2001/XMLSchema}anyURI" />
* &lt;attribute name="width" type="{http://www.w3.org/2001/XMLSchema}short" />
* &lt;attribute name="height" type="{http://www.w3.org/2001/XMLSchema}short" />
* &lt;attribute name="lang" type="{http://www.w3.org/2001/XMLSchema}string" />
* &lt;attribute name="href" type="{http://www.w3.org/2001/XMLSchema}anyURI" />
* &lt;/restriction>
* &lt;/complexContent>
* &lt;/complexType>
* &lt;/element>
* &lt;element name="ratings">
* &lt;complexType>
* &lt;simpleContent>
* &lt;extension base="&lt;http://www.w3.org/2001/XMLSchema>string">
* &lt;attribute name="nb_votes" type="{http://www.w3.org/2001/XMLSchema}short" />
* &lt;attribute name="weighted_score" type="{http://www.w3.org/2001/XMLSchema}float" />
* &lt;attribute name="bayesian_score" type="{http://www.w3.org/2001/XMLSchema}float" />
* &lt;/extension>
* &lt;/simpleContent>
* &lt;/complexType>
* &lt;/element>
* &lt;element name="episode" maxOccurs="unbounded" minOccurs="0">
* &lt;complexType>
* &lt;complexContent>
* &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* &lt;sequence>
* &lt;element name="title">
* &lt;complexType>
* &lt;simpleContent>
* &lt;extension base="&lt;http://www.w3.org/2001/XMLSchema>string">
* &lt;attribute name="gid" type="{http://www.w3.org/2001/XMLSchema}long" />
* &lt;attribute name="lang" type="{http://www.w3.org/2001/XMLSchema}string" />
* &lt;/extension>
* &lt;/simpleContent>
* &lt;/complexType>
* &lt;/element>
* &lt;/sequence>
* &lt;attribute name="num" type="{http://www.w3.org/2001/XMLSchema}byte" />
* &lt;/restriction>
* &lt;/complexContent>
* &lt;/complexType>
* &lt;/element>
* &lt;element name="review" maxOccurs="unbounded" minOccurs="0">
* &lt;complexType>
* &lt;simpleContent>
* &lt;extension base="&lt;http://www.w3.org/2001/XMLSchema>string">
* &lt;attribute name="href" type="{http://www.w3.org/2001/XMLSchema}anyURI" />
* &lt;/extension>
* &lt;/simpleContent>
* &lt;/complexType>
* &lt;/element>
* &lt;element name="release" maxOccurs="unbounded" minOccurs="0">
* &lt;complexType>
* &lt;simpleContent>
* &lt;extension base="&lt;http://www.w3.org/2001/XMLSchema>string">
* &lt;attribute name="date" type="{http://www.w3.org/2001/XMLSchema}date" />
* &lt;attribute name="href" type="{http://www.w3.org/2001/XMLSchema}anyURI" />
* &lt;/extension>
* &lt;/simpleContent>
* &lt;/complexType>
* &lt;/element>
* &lt;element name="news" maxOccurs="unbounded" minOccurs="0">
* &lt;complexType>
* &lt;simpleContent>
* &lt;extension base="&lt;http://www.w3.org/2001/XMLSchema>string">
* &lt;attribute name="datetime" type="{http://www.w3.org/2001/XMLSchema}dateTime" />
* &lt;attribute name="href" type="{http://www.w3.org/2001/XMLSchema}anyURI" />
* &lt;/extension>
* &lt;/simpleContent>
* &lt;/complexType>
* &lt;/element>
* &lt;element name="staff" maxOccurs="unbounded" minOccurs="0">
* &lt;complexType>
* &lt;complexContent>
* &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* &lt;sequence>
* &lt;element name="task" type="{http://www.w3.org/2001/XMLSchema}string"/>
* &lt;element name="person">
* &lt;complexType>
* &lt;simpleContent>
* &lt;extension base="&lt;http://www.w3.org/2001/XMLSchema>string">
* &lt;attribute name="id" type="{http://www.w3.org/2001/XMLSchema}int" />
* &lt;/extension>
* &lt;/simpleContent>
* &lt;/complexType>
* &lt;/element>
* &lt;/sequence>
* &lt;attribute name="gid" type="{http://www.w3.org/2001/XMLSchema}long" />
* &lt;/restriction>
* &lt;/complexContent>
* &lt;/complexType>
* &lt;/element>
* &lt;element name="cast" maxOccurs="unbounded" minOccurs="0">
* &lt;complexType>
* &lt;complexContent>
* &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* &lt;sequence>
* &lt;element name="role" type="{http://www.w3.org/2001/XMLSchema}string"/>
* &lt;element name="person">
* &lt;complexType>
* &lt;simpleContent>
* &lt;extension base="&lt;http://www.w3.org/2001/XMLSchema>string">
* &lt;attribute name="id" type="{http://www.w3.org/2001/XMLSchema}int" />
* &lt;/extension>
* &lt;/simpleContent>
* &lt;/complexType>
* &lt;/element>
* &lt;/sequence>
* &lt;attribute name="gid" type="{http://www.w3.org/2001/XMLSchema}long" />
* &lt;attribute name="lang" type="{http://www.w3.org/2001/XMLSchema}string" />
* &lt;/restriction>
* &lt;/complexContent>
* &lt;/complexType>
* &lt;/element>
* &lt;element name="credit" maxOccurs="unbounded" minOccurs="0">
* &lt;complexType>
* &lt;complexContent>
* &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* &lt;sequence>
* &lt;element name="task" type="{http://www.w3.org/2001/XMLSchema}string"/>
* &lt;element name="company">
* &lt;complexType>
* &lt;simpleContent>
* &lt;extension base="&lt;http://www.w3.org/2001/XMLSchema>string">
* &lt;attribute name="id" type="{http://www.w3.org/2001/XMLSchema}short" />
* &lt;/extension>
* &lt;/simpleContent>
* &lt;/complexType>
* &lt;/element>
* &lt;/sequence>
* &lt;attribute name="gid" type="{http://www.w3.org/2001/XMLSchema}long" />
* &lt;/restriction>
* &lt;/complexContent>
* &lt;/complexType>
* &lt;/element>
* &lt;/sequence>
* &lt;attribute name="id" type="{http://www.w3.org/2001/XMLSchema}short" />
* &lt;attribute name="gid" type="{http://www.w3.org/2001/XMLSchema}int" />
* &lt;attribute name="type" type="{http://www.w3.org/2001/XMLSchema}string" />
* &lt;attribute name="name" type="{http://www.w3.org/2001/XMLSchema}string" />
* &lt;attribute name="precision" type="{http://www.w3.org/2001/XMLSchema}string" />
* &lt;attribute name="generated-on" type="{http://www.w3.org/2001/XMLSchema}dateTime" />
* &lt;/restriction>
* &lt;/complexContent>
* &lt;/complexType>
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
"info",
"ratings",
"episode",
"review",
"release",
"news",
"staff",
"cast",
"credit"
})
public static class Anime {

protected List<Ann.Anime.Info> info;
@XmlElement(required = true)
protected Ann.Anime.Ratings ratings;
protected List<Ann.Anime.Episode> episode;
protected List<Ann.Anime.Review> review;
protected List<Ann.Anime.Release> release;
protected List<Ann.Anime.News> news;
protected List<Ann.Anime.Staff> staff;
protected List<Ann.Anime.Cast> cast;
protected List<Ann.Anime.Credit> credit;
@XmlAttribute(name = "id")
protected Short id;
@XmlAttribute(name = "gid")
protected Integer gid;
@XmlAttribute(name = "type")
protected String type;
@XmlAttribute(name = "name")
protected String name;
@XmlAttribute(name = "precision")
protected String precision;
@XmlAttribute(name = "generated-on")
@XmlSchemaType(name = "dateTime")
protected XMLGregorianCalendar generatedOn;

/**
* Gets the value of the info property.
*
* <p>
* This accessor method returns a reference to the live list,
* not a snapshot. Therefore any modification you make to the
* returned list will be present inside the JAXB object.
* This is why there is not a <CODE>set</CODE> method for the info property.
*
* <p>
* For example, to add a new item, do as follows:
* <pre>
* getInfo().add(newItem);
* </pre>
*
*
* <p>
* Objects of the following type(s) are allowed in the list
* {@link Ann.Anime.Info }
*
*
*/
public List<Ann.Anime.Info> getInfo() {
if (info == null) {
info = new ArrayList<Ann.Anime.Info>();
}


ObjectFactory.java , this was generated alongside the Ann class ... not sure what it does, maybe i need to use it or maybe it was used by the system in generating the Ann and i dont need it anymore..... or maybe its used automatically in processing XML data to put it into the Ann class, in which case i DO need to use it somewhere (unless its used super-automatically)

+ Show Spoiler +

//
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.5-2
// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
// Any modifications to this file will be lost upon recompilation of the source schema.
// Generated on: 2015.03.03 at 05:12:35 PM GMT
//


package generated;

import javax.xml.bind.JAXBElement;
import javax.xml.bind.annotation.XmlElementDecl;
import javax.xml.bind.annotation.XmlRegistry;
import javax.xml.namespace.QName;


/**
* This object contains factory methods for each
* Java content interface and Java element interface
* generated in the generated package.
* <p>An ObjectFactory allows you to programatically
* construct new instances of the Java representation
* for XML content. The Java representation of XML
* content can consist of schema derived interfaces
* and classes representing the binding of schema
* type definitions, element declarations and model
* groups. Factory methods for each of these are
* provided in this class.
*
*/
@XmlRegistry
public class ObjectFactory {

private final static QName _AnnAnimeInfoImg_QNAME = new QName("", "img");

/**
* Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: generated
*
*/
public ObjectFactory() {
}

/**
* Create an instance of {@link Ann }
*
*/
public Ann createAnn() {
return new Ann();
}

/**
* Create an instance of {@link Ann.Anime }
*
*/
public Ann.Anime createAnnAnime() {
return new Ann.Anime();
}

/**
* Create an instance of {@link Ann.Anime.Credit }
*
*/
public Ann.Anime.Credit createAnnAnimeCredit() {
return new Ann.Anime.Credit();
}

/**
* Create an instance of {@link Ann.Anime.Cast }
*
*/
public Ann.Anime.Cast createAnnAnimeCast() {
return new Ann.Anime.Cast();
}

/**
* Create an instance of {@link Ann.Anime.Staff }
*
*/
public Ann.Anime.Staff createAnnAnimeStaff() {
return new Ann.Anime.Staff();
}

/**
* Create an instance of {@link Ann.Anime.Episode }
*
*/
public Ann.Anime.Episode createAnnAnimeEpisode() {
return new Ann.Anime.Episode();
}

/**
* Create an instance of {@link Ann.Anime.Info }
*
*/
public Ann.Anime.Info createAnnAnimeInfo() {
return new Ann.Anime.Info();
}

/**
* Create an instance of {@link Ann.Anime.Ratings }
*
*/
public Ann.Anime.Ratings createAnnAnimeRatings() {
return new Ann.Anime.Ratings();
}

/**
* Create an instance of {@link Ann.Anime.Review }
*
*/
public Ann.Anime.Review createAnnAnimeReview() {
return new Ann.Anime.Review();
}

/**
* Create an instance of {@link Ann.Anime.Release }
*
*/
public Ann.Anime.Release createAnnAnimeRelease() {
return new Ann.Anime.Release();
}

/**
* Create an instance of {@link Ann.Anime.News }
*
*/
public Ann.Anime.News createAnnAnimeNews() {
return new Ann.Anime.News();
}

/**
* Create an instance of {@link Ann.Anime.Credit.Company }
*
*/
public Ann.Anime.Credit.Company createAnnAnimeCreditCompany() {
return new Ann.Anime.Credit.Company();
}

/**
* Create an instance of {@link Ann.Anime.Cast.Person }
*
*/
public Ann.Anime.Cast.Person createAnnAnimeCastPerson() {
return new Ann.Anime.Cast.Person();
}

/**
* Create an instance of {@link Ann.Anime.Staff.Person }
*
*/
public Ann.Anime.Staff.Person createAnnAnimeStaffPerson() {
return new Ann.Anime.Staff.Person();
}

/**
* Create an instance of {@link Ann.Anime.Episode.Title }
*
*/
public Ann.Anime.Episode.Title createAnnAnimeEpisodeTitle() {
return new Ann.Anime.Episode.Title();
}

/**
* Create an instance of {@link Ann.Anime.Info.Img }
*
*/
public Ann.Anime.Info.Img createAnnAnimeInfoImg() {
return new Ann.Anime.Info.Img();
}

/**
* Create an instance of {@link JAXBElement }{@code <}{@link Ann.Anime.Info.Img }{@code >}}
*
*/
@XmlElementDecl(namespace = "", name = "img", scope = Ann.Anime.Info.class)
public JAXBElement<Ann.Anime.Info.Img> createAnnAnimeInfoImg(Ann.Anime.Info.Img value) {
return new JAXBElement<Ann.Anime.Info.Img>(_AnnAnimeInfoImg_QNAME, Ann.Anime.Info.Img.class, Ann.Anime.Info.class, value);
}

}



getservice.java, this gets the xml file from animenewsnetwork , it works in that you can print the response to a string but i dont know if it successfully parses the response into the Ann class like i have it right now. i think i should run it with a breakpoint and see if anything comes up there...... the thing is, i cant just "run" that file coz it says there's no Main file, so i went next to make a main file

+ Show Spoiler +

/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package javaapplication4;

import generated.Ann;
import javax.annotation.PostConstruct;
import javax.enterprise.context.ApplicationScoped;
import javax.ws.rs.client.Client;
import javax.ws.rs.client.ClientBuilder;
import javax.ws.rs.client.WebTarget;
import javax.ws.rs.core.MediaType;

/**
*
* @author J
*/
@ApplicationScoped
public class getservice {

private Client client;
private WebTarget target;

@PostConstruct
protected void init() {
client = ClientBuilder.newClient();
//target = client.target("http://www.omdbapi.com");
target = client.target("http://cdn.animenewsnetwork.com/encyclopedia/api.xml");
}

public Ann fetchMovie() {
//return target.queryParam("anime", "4658")
return target.queryParam("anime", "4658")
.request(MediaType.TEXT_HTML)
.header("Content-type", "text/html")//application_json or text_html or xml
.get(Ann.class);
}



JavaAPplication4.java , ....i went to make this Main so it would run, i guess i dont need it if i can wrap the service in a Main function but im not sure if that will just tell me to fuck off, ill go try it right now. in the meantime, this is where i possibly want to call my service and print a result...... you can see the missing line here which doesnt do anything:
String output = fetchMovie(Ann ann).getName();

+ Show Spoiler +


package javaapplication4;

import generated.Ann;

public class JavaApplication4 {

public static void main(String[] args) {

try {


String output = fetchMovie(Ann ann).getName();



System.out.println(output);

} catch (Exception e) {

e.printStackTrace();

}
}
}


thanksXD
Cool BW Music Vid - youtube.com/watch?v=W54nlqJ-Nx8 ~~~~~ ᕤ OYSTERS ᕤ CLAMS ᕤ AND ᕤ CUCKOLDS ᕤ ~~~~~~ ༼ ᕤ◕◡◕ ༽ᕤ PUNCH HIM ༼ ᕤ◕◡◕ ༽ᕤ
Prev 1 596 597 598 599 600 1032 Next
Please log in or register to reply.
Live Events Refresh
Next event in 4h 8m
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
mouzHeroMarine 686
ProTech105
IndyStarCraft 99
JuggernautJason86
RushiSC 16
StarCraft: Brood War
sSak 52
scan(afreeca) 48
Dota 2
Gorgc4875
canceldota62
Counter-Strike
fl0m3356
byalli812
Heroes of the Storm
Liquid`Hasu264
Khaldor163
Other Games
gofns46544
tarik_tv16175
Grubby2536
FrodaN1580
Beastyqt679
summit1g659
B2W.Neo526
KnowMe465
DeMusliM169
C9.Mang0111
Livibee61
Organizations
Dota 2
PGL Dota 2 - Main Stream13987
Other Games
gamesdonequick1722
ComeBackTV 275
BasetradeTV72
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 18 non-featured ]
StarCraft 2
• StrangeGG 52
• Kozan
• LaughNgamezSOOP
• sooper7s
• AfreecaTV YouTube
• intothetv
• Migwel
• IndyKCrew
StarCraft: Brood War
• blackmanpl 42
• RayReign 6
• STPLYoutube
• ZZZeroYoutube
• BSLYoutube
Dota 2
• lizZardDota255
League of Legends
• Doublelift1287
• TFBlade1280
Other Games
• imaqtpie1139
• Shiphtur175
Upcoming Events
Replay Cast
4h 8m
CranKy Ducklings
14h 8m
RSL Revival
14h 8m
MaxPax vs Rogue
Clem vs Bunny
WardiTV Team League
16h 8m
uThermal 2v2 Circuit
21h 8m
BSL
1d
Sparkling Tuna Cup
1d 14h
RSL Revival
1d 14h
ByuN vs SHIN
Maru vs Krystianer
WardiTV Team League
1d 16h
Patches Events
1d 21h
[ Show More ]
BSL
2 days
Replay Cast
2 days
Replay Cast
2 days
Wardi Open
2 days
Monday Night Weeklies
2 days
WardiTV Team League
3 days
GSL
4 days
The PondCast
5 days
WardiTV Team League
5 days
Replay Cast
6 days
WardiTV Team League
6 days
Liquipedia Results

Completed

Proleague 2026-03-12
WardiTV Winter 2026
Underdog Cup #3

Ongoing

KCM Race Survival 2026 Season 1
Jeongseon Sooper Cup
BSL Season 22
Proleague 2026-03-13
RSL Revival: Season 4
Nations Cup 2026
ESL Pro League S23 Finals
ESL Pro League S23 Stage 1&2
PGL Cluj-Napoca 2026
IEM Kraków 2026
BLAST Bounty Winter 2026
BLAST Bounty Winter Qual

Upcoming

CSL Elite League 2026
ASL Season 21
Acropolis #4 - TS6
2026 Changsha Offline CUP
Acropolis #4
IPSL Spring 2026
CSLAN 4
HSC XXIX
uThermal 2v2 2026 Main Event
NationLESS Cup
CS Asia Championships 2026
Asian Champions League 2026
IEM Atlanta 2026
PGL Astana 2026
BLAST Rivals Spring 2026
CCT Season 3 Global Finals
IEM Rio 2026
PGL Bucharest 2026
Stake Ranked Episode 1
BLAST Open Spring 2026
TLPD

1. ByuN
2. TY
3. Dark
4. Solar
5. Stats
6. Nerchio
7. sOs
8. soO
9. INnoVation
10. Elazer
1. Rain
2. Flash
3. EffOrt
4. Last
5. Bisu
6. Soulkey
7. Mini
8. Sharp
Sidebar Settings...

Advertising | Privacy Policy | Terms Of Use | Contact Us

Original banner artwork: Jim Warren
The contents of this webpage are copyright © 2026 TLnet. All Rights Reserved.