announcements‎ > ‎

2015-10-15 HW11

posted Oct 15, 2015, 1:19 PM by Samuel Konstantinovich   [ updated Oct 15, 2015, 1:21 PM ]
1. Create the Actor Class.

public class Actor{
    private String name;
    private int strength,agility,intelligence;
    private int health;

    //actor constructor to initialize all instance variables
    public Actor(String name, int str, int agi, int intel, int health){
        this.name = name;
        agility = agi;
        strength = str;
        intelligence = intel;
        this.health = health;
    }

    //specific named actor
    public Actor(String name){
        this(name,10,10,10,20);
    }

    //generic named actor
    public Actor(){
        this("Joe Dirt",10,10,10,20);
    }

    //You must write these methods:
    public String getName(){}
    public int getInt(){}
    public int getStr(){}
    public int getAgi(){}
    public int getHealth(){}
    public int takeDamage(int damage){}
    public String attack(){}
    public String specialAttack(){}
}

2. Create a Wizard class that:
-extends the Actor class
-Overrides all three constructors
-Overrides attack, specialAttack
Methods that have the same header in a sub class will be called instead of the super class counterpart, this will be demonstrated tomorrow. 

3. Vote on the form on piazza.
Comments