0

ok so I want to make a game but am having some difficulty in getting the class diagram sorted.

this would be for the Use case of : user Equips weapon. (user can select unlocked weapons only,) what would the class diagram of this look like with 2 weapons for instance ? thanks in advance

RY4N
  • 1,080
  • 3
  • 14
  • 31

2 Answers2

0

Eh, what? Could you ask more specific questions?

Or at least provide what you already have?

You probably do already have player and weapon classes, right?

Class player (what you named user) with a one-way association with multiplicity * to weapons named unlockedWeapons to the class weapon. Another association to the class weapon named currentWeapon with multiplicity 1, also one-way.

Class player then gets some methods, like equip(Weapon weapon) which gets a Weapon object, checks for validity (is it unlocked) etc.

Whether it’s 2 weapons or not is irrelevant. If you mean 2 different types of weapons, which are subclasses inheriting the Weapon class, the player probably still associates with Weapons for abstraction.

Designing a class diagram for that is really the most basic thing to do in UML modeling / software design.

Kissaki
  • 8,810
  • 5
  • 40
  • 42
  • the weapons would be different but very similar, for example a pistol and shoutgun, different models/soundbites – RY4N Dec 10 '10 at 03:51
0

Here is an example UML diagram modeling the relationships you describe in your question. Note that this diagram assumes that the player always has at least one weapon unlocked and that the player always has one and only one selected weapon.

alt text

Brandon E Taylor
  • 24,881
  • 6
  • 47
  • 71