2014-10-08 LAB

posted Oct 8, 2014, 9:06 AM by Samuel Konstantinovich   [ updated Oct 8, 2014, 10:40 AM ]
1. Write the classes without methods:

Adventurer
  instance variables:  name, HP

Warrior
  instance variable:  bonusHealth

Mage
  instance variable: mana

2. Before you worry about setter/getters: test what happens when you have a single constructor for Adventurer that allows a String to be passed into it. There should be no other constructors (comment out your default constructor).

2a. Now try this in your main:
Adventurer p1 = new Adventurer("Bob");
2b. Now try this in your main:
Adventurer p1 = new Adventurer("Bob");
Warrior p2 = new Warrior();

Now Fix the problem created by part 2 by putting the default constructor back.

3. You need write get/set methods in the appropriate location for:
name,HP,mana 

4. You need to override the getHP inside Warrior to utilize bonusHealth.

5. Use the super() constructor and the this() constructor when appropriate to make your code cleaner. We will discuss this tomorrow.



Comments