Monday 15 April 2013

Group Activity - Inheritance



A Player has the following attributes: 

  • Name
  • Health
  • Strength
  • intelligence
  • Location
    • X coordinate
    • Y coordinate
  • Inventory
    • a collection of InventoryItem's - each InventoryItem has the following attributes
      • ID
      • Price
      • Weight.
A Weapon is a type of InventoryItem. It has a single int attribute: DPS. 
  • An object of Weapon type may be constructed with or without providing a value for this attribute. 
    • A Gun is a type of Weapon. It has a single int attribute: ammoCount. A value for this attribute must be provided in the constructor. 
    • A Stick is a type of Weapon. It has a single int attribute: stickLength. A value for this attribute must be provided in the constructor.


A Tool is a type of InventoryItem. It has a single int attribute: numberOfUses. 

  • An object of Tool type may be constructed with or without providing a value for this attribute. 
    • A Key is a type of Tool. It has a single String attribute: keyName. A value for this attribute must be provided in the constructor. 
    • A Mirror is a type of Tool. It has a single String attribute: mirrorName. A value for this attribute must be provided in the constructor.


Original Post Jul 29th 2012

No comments:

Post a Comment