Computer Science Canada Simulator display issues |
Author: | Tallguy [ Mon Mar 07, 2011 6:34 pm ] | ||
Post subject: | Simulator display issues | ||
Hello hello, I for my assignment it is to continue on the steps to creating a fully working LoTR battle simulator, each assignment building off each other. This assignment to is randomize 'actor' variables (name/speed etc) for a user defined army (light/dark) and for a size that they speficify. Im kinda new to java so . . . -we need a array of refences that refernecs individual 'actors' then display everything to the screen
im having a problem with displaying all the data together on one GUI screen, each class 'sends' it data forward but i cant seem to get the data to display i get 'ActorFatcory@15443e54' for each actor?? Why is this doing it? |
Author: | Tony [ Mon Mar 07, 2011 7:23 pm ] | ||||||
Post subject: | RE:Simulator display issues | ||||||
1) Generics make Java suck less.
No casting. No off-by-one errors. Awesome APIs for the data structure. Quote: 'ActorFatcory@15443e54' for each actor Yes, you're assigning an ActorFactory instead of an Actor.
A factory pattern is typically used as:
But that only makes sense if creation of new instances involves processes outside of a typical constructor. |
Author: | DemonWasp [ Mon Mar 07, 2011 8:01 pm ] |
Post subject: | RE:Simulator display issues |
The default implementation of the toString() method returns ClassName@Address. To make it display something else, override it by adding a method with this exact signature: public String toString() With an implementation that returns a String representing your Actor. |
Author: | Tallguy [ Tue Mar 08, 2011 11:33 am ] | ||||
Post subject: | Re: Simulator display issues | ||||
awesome ty, Tony i would use arraylist, but for this assignment we are not allowed. This is what i did, and something in another class to fix my previous error
now the only problem i have is..... To display all the data i have used:
why is 'null;' still showing up? it says "Army of light;null;.....data", what can i do to get rid of this? |
Author: | Tony [ Tue Mar 08, 2011 1:15 pm ] | ||
Post subject: | RE:Simulator display issues | ||
So it seems that null is from outPutLight in
Search for the use of the name to see where you create this field, and how it is populated with data. |