CS 201: Inheritance Practice (pair assignment)

This is a pair programming assignment. If you are on a team, this means that you and your partner should be doing the entirety of this assignment side-by-side, on a single computer, where one person is "driving" and the other is "navigating." Take turns every so often who is driving; you should each spend approximately 50% of the time driving.


Here is an interface that represents a virtual Pet.

public interface Pet
{
    void reward(int numTimes);
    void punish(int numTimes);
    void act();
}

Your task is to create two implementation classes for Pet, named Dog and Cat. Each one of them should implement the three methods above appropriately, as well as contain a relevant constructor. Here are some more details:

If you've written your class correctly, the following test code should work if you place it inside an appropriate main method:

    Pet fido = new Dog();
    Pet socks = new Cat();

    fido.reward(5);
    socks.punish(3);

    fido.act();
    socks.act();

Note that starting with this assignment, we will also be grading your submitted code for good style. This style guide contains ideas for good style that you should be observing.