Skip to main content

Homework 10: Bryn Mawr Vet in need of a Java Programmer

The goals of this assignment are:

Requirements:

WARNING: In this assignment you are NOT ALLOWED to import any packages. For example, you cannot use the builtin Arrays java class to print out an array. Doing so will result in earning ZERO POINTS for a method that uses it.

IF YOUR CODE DOES NOT COMPILE, YOUR SUBMISSION WILL BE DEDUCTED ATLEAST 50%.

1. Overview

Once upon a time, there was a small veterinary clinic that needed help managing their records. They had tried using paper records, but they found it was too difficult to keep track of everything. They decided to hire a Java programmer to create a program that would help them manage their records more efficiently.

As part of your Intro to CS in Java course, your professor has assigned you to develop this program for the vet clinic. You’ll be using your Java skills to create a program that can keep track of all the animals, their owners, and some more information.

The vet clinic has provided you with some basic requirements for the program. They want to be able to add new animals, remove animals, determine the average cost of each visit for an animal. Some of the requirements for what a Vet must do are detailed in the Java interface called Database.java.

Your task is to create a solution that meets these requirements. You’ll be using object-oriented programming principles to create classes for Pets, and some specific type of pets (detailed in HW10Driver.java).

As you work on this assignment , you’ll have the opportunity to practice important object-oriented programming concepts, such as inheritance, polymorphism, and encapsulation.

At the end of the project, you’ll present your program to the vet clinic (by uploading your solution to Gradescope ofcourse), and they’ll be able to use it to manage their records more efficiently. You’ll have made a real-world impact with your programming skills, and you’ll have gained valuable experience that will help you in your future programming projects.

The clinic has given you a driver program called HW10Driver.java that should work after you implement the required classes.

The text file driverResults.txt shows what the results of running java HW10Driver should be.

You can find the three files by appending them to this url: https://bmc-cs-113.github.io/hws/hw10/.

WARNING: You are NOT allowed to edit HW10Driver.java or Database.java

2. Details

2.1 Costs for visits

Each time an animal visits the clinic, the owner has to pay a fee. The fee depends on the following criteria:

The base cost for a visit is $85.00, and $30 is added for every shot.

Any time a dog visits the clinic, the dog’s nails are trimmed (costing $25). Additionally, since more help is needed for giving shots to different sized dogs (see the driver for the options for dog sizes), the clinic adds a surcharge of $5.50 per shot for medium dogs and $12.75 per shot for large dogs.

Any time a dog cat visits the clinic, the cat gets a teeth cleaning. Since there is a short supply of FDA-approved cat toothpase, a cat’s teeth cleaning is $40.

Any time an outside cat visits the clinic, it must get an additional shot.

Database interface

You will notice that the methods in the Database interface a very generic in that they take in Objects as parameters.

For some of the methods, you will have to check the type of object that is being passed in. You can use instanceOf

String one = "one";
boolean isString = one instanceOf String;

The boolean variable named isString will then take on the value true.

Type Casting Recall from earlier in the semester that type casting allows us to converف the type of a value stored in a variable. From page 46 of the text, the syntax for type casting is to put the name of the type in parentheses and use it as an operator:

double pi = 3.14159;
int x = (int) pi;

Here, the value in x will be 3.

We can use type casting to convert the types of objects as well. This code shows how to use type casting to convert a simple object to a CustomType object.\

Object a = new Object()
CustomeType newVar = (CustomType) a

README.txt

In a text file called README.txt answer the following questions:

  1. How much time did you spend on the homework
  2. What did you learn from this homework
  3. optional: What did you struggle with during this homework
  4. optional: any other feedback you would like to share

Dont forget: make sure to fill in the header in all of your java files.

Submitting

Submit all java files you created and README.txt to the assignment called HW10 on Gradescope. Do not upload HW10Driver.java or Database.java.