Starting from:

$30

CSC220-Lab 9 Class Design Solved

Complete several small programs in Java based on examples in class. In this lab, you will
play with class design.
Java programs:
Dog Class
• Design and implement a class called Dog that contains instance data that represents
the dog’s name and age. Define the Dog constructor to accept and initialize instance
data. Include getter and setter methods for the name and age. The getter names
MUST be “getName” and “getAge”. The setter names must be “setName” and
“setAge”. Include a method to compute and return the age of the dog in “person
years” (seven times the dog’s age). Include a toString method that returns a oneline description of the dog. Create a driver class called Kennel, whose main method
instantiates and updates several Dog objects.
Die Class
• Using the Die class defined in slides 07_Writing_Classes.pdf, design and implement
a class called PairOfDice, composed of two Die objects. Include methods to set and
get the individual die values, a method to roll the dice, and a method that returns
the current sum of the two die values. Create a driver class called RollingDice2 to
instantiate and use a PairOfDice object. The driver should call each method of the
PairOfDice object

More products