0

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.

2
Contributors
3
Replies
4
Views
8 Years
Discussion Span
Last Post by samuel_pay
0

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.

0

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

0

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

Attachments wargame_copy.jpg 143.88 KB
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.