Okay ive started doing my UML but i was just wondering with regards to instance variables. i will try and explain it as best as i can but im a complete noobie to be honest.

with regards to my last post as i am implementing a program in java of a battle war game. As all of my subclasses from the "army" class are going to have Hit points, movement points and attack points do i put those instances in there respective classes or do i put them into the army class to be held and then called from the sub classes? each subclass will have a different variable of hit point, movement point and attack points. and will this be a case od incapulation or something els? thanks

sorry for the total lack of knowledge on this.

Don't forget what classes are for!

Classes are things capable of having behavior and encapsulating information.

Encapsulated information can be data, but it's slightly beyond just that.

Behavior can be considered a method, but it's slightly beyond that as well.

If you're not worried about the stats of a unit changing, I'd most likely place that information in the abstract unit class and each derived unit can have the same stats with different values.

This isn't encouraged though - chances are you will want a Stat class that holds the information of the stats.

Don't forget what classes are for!

Classes are things capable of having behavior and encapsulating information.

Encapsulated information can be data, but it's slightly beyond just that.

Behavior can be considered a method, but it's slightly beyond that as well.

If you're not worried about the stats of a unit changing, I'd most likely place that information in the abstract unit class and each derived unit can have the same stats with different values.

This isn't encouraged though - chances are you will want a Stat class that holds the information of the stats.

oooooo i didnt even think of that, thats a great plan. Making a stats class now... cheers mate

alright have a look at my attachment of the image i have done for my UML and tell me if you think its right or not. and if not suggest any improvements pllllleeeeaaaase

sam

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.