# Dogs - 15-121: Introduction to Data StructuresFall

This preview shows pages 1–2. Sign up to view the full content.

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: 15-121: Introduction to Data StructuresFall 2009Exercise09/03/2009DogsDue: Fri, Sept 118am Relevant Reading:Chapters 1-5 of the online text by Eck.Sample Programs and Dates and Bank Accounts Assignment: (worth 10 exercise points) Use the files in Dogs.zip. In this assignment, you are to create two classes, Dog and ShowDog. They should meet the specifications below. Dog:The class represents dogs that have a name (a String), a breed (a String), and an age (an integer in years).There are two constructors with the following headers:public Dog (String name, String breed, int age)public Dog(String name, String breed) // assumes the age is 0The following methods:public String getName()public String getBreed()public int getAge()public String toString() // returns a string in the following form:// name, a breed, is n years old.public void oneYearOlder() // adds one to the age of the dogShowDog:This class represents dogs that are winning points at dog shows. Dogs that have at least 15 points are considered to be champions. This class should extend Dog. There are three constructors with the following headers:public ShowDog(String n, String b, int age, int pts)public ShowDog(String n, String b, int pts) // assumes age 0public ShowDog(String n, String b) // assumes age 0 and points 0The following methods should be available to instances of ShowDog:public String getName()public String getBreed()public int getAge()public int getPoints()public String toString() // returns a string in the following form:// name, a breed, is n years old. with p points, Champion or non-Championpublic void oneYearOlder() // adds one to the age of the dogpublic boolean isChampion() // true if points at least 15, false otherwisepublic void addPoints(int p) // add the parameter to the number of pointsTesting:You are provided with testing code that will test to see that your classes are correct. You are provided with testing code that will test to see that your classes are correct....
View Full Document

## Dogs - 15-121: Introduction to Data StructuresFall

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online