// in general, it could be potion, armor, weapon, etc.
Item class {
// states
id
name
// behavior
set, get of states here..
use()
// still thinking what is the other general behavior
}
// in general, it could be Gun,Sword,Wand, Bow (range,melee,magic)
Weapon class extends Item{
// gun - fire(); type: range (in the movie, the gun can be use as melee weapon too xD)
// sword - slash(); type: melee (in the movie, the sword can be thrown :) or use as magic wand?)
// wand - ??
// mace - bash();
// bow - shoot() ??
// so what is the general behavior of this weapon?
}
Bag class {} // parent is Item, collection of items here
// Human, Orc, etc
Character class {
// states
Weapon
// behavior
attack();
// still thinking what is the other behavior and states
}
// Swordsman, Magician, Archer, etc.
Hero class extends Character{
}
The above code is my OOP classes of Role Playing Game that I am developing, and I'm having hard time thinking of the general states and behavior of each classes.
Problem
- How do I create these classes (I am beginner in OOP). I've heard some encapsulations, polymorphish etc.
- I don't know how to use properly the interface, abstract etc.
- Thinking of the general states and behavior of classes
- As you can see in the weapon class. The gun, sword, bow can be use as melee, range, or even magic. And should I call these WeaponType? (range,melee,magic)