CS113 Assignment 8: Veterinarian Facility - More Classes & Objects

Due Thursday, November 10, before midnight

Goals

  • Working with arrays

  • Subtyping and Subclassing

  • Use lists and classes to store data

  • Linear Search

You are given basecode for this assignment. Check your A08 folder on dropbox to get started!

credit: Joanne Selinski

Overview

For this assignment, you will create classes to implement a Veterinary Facility. We have specified classes that you must implement to build and support a Veterinary Facility using inheritance (subclassing) and interfaces (subtyping).

1. Pet class

Create a class called Pet.java to maintain a Pet record.

Data:

  • name (String)

  • owner’s name (String)

  • weight (Weight)

  • along with other features necessary to implement the class methods (look at the starter code).

Methods:

  • Constructor. This function should initialize the data inside Pet

  • Accessors for the instance variables

  • equals(Pet otherPet) - this will override the default Object equals method. Two Pets are equal if their name and their owner’s names are the same, ignoring capitalization.

We will provide a skeleton of the required methods for this class (called PetStarter.java), along with documentation to clarify the purpose of each. You will need to determine what data members are necessary to represent a Pet object, and what additional methods might be necessary.

You are welcome to add other methods to this class in order to support the other features.

2. Cat class

Create a class called Cat that is a subclass of the Pet class.

Data:

  • isInsideCat (boolean) - determine if the cat is an inside cat or if it goes outside sometimes.

  • owner’s name (String)

Methds:

  • public void goOutside() - changes a house cat to an outside cat (once a cat becomes an outside cat it will always be an outside cat.)

Override the Pet base class’s visit method so that each visit includes 1) a $40 teeth cleaning, 2) an extra shot for outside cats. Make sure when you override this method that any related data members in the Pet class are being updated correctly. (Hint: start by calling the visit method in the Pet class.) You are writing this class from scratch.

3. Dog class

Create a class called Dog that is a subclass of the Pet class.

Data:

  • size (String) - a dog can be small, medium, or large (make sure to pass this information to the constructor).

Override the visit() method so that every visit includes 1) a nail trimming costing $25 and 2) a surcharge of $5.50 per shot for medium dogs and $12.75 for large dogs. Make sure when you override this method that any related data members from the Pet class are being updated correctly. (Hint: start by calling the visit method in the Pet class.) You are writing this class from scratch.

4. Vet class

Create a class called Vet that implements the Database interface.

Data:

  • name (String) - the name of the veterinary office

  • pets (Pet[]) - the collection of pets

We have provided a starter class for you called VetStarter.java.

Requirement/Note: the Vet class must implement the add and delete methods that respectively add and delete a pet from the list. Make sure the order of the list stays the same. Before implementing these two functions, it is highly recommend you sketch out what happens in the array to the remaining elements when you remove/delete a pet from the array. of pets currently in the array.

5. Testing

Each class you implement must include tests that determine that the implementations for the class are correct. Use the main method in each class to test your implementations.

We have also provided a file called Asst08Driver.java that will test your code. You must not change this program or the provided interface (Database.java) in any way,

6. What to hand-in

  1. The programs, Pet.java, Dog.java, Cat.java, Vet.java

  2. The programs, Asst08Driver.java, Database.java

  3. Make sure your programs have a header containing your name, date, and description.

  4. Make sure any new method you write includes a javadoc.

  5. Make sure you use the correct access modifiers for instance variables and methods (all data members should be private, unless they need to be protected).

  6. Make sure your program can run from the Dropbox directory. You should include the data files and any supporting files your program needs to run.

  7. A brief write-up containing your name, assignment number, and a few sentences about how long you spent on the assignment and any interesting customizations you made.

6.1. How to hand-in

  1. Copy your files to your dropbox, into the folder called A08.