CPSC-115 Fall 2008
Lab 9
October 28-29, 2008
Professor Heidi Ellis
Be sure that you hand in the printouts of your work before leaving!!!
Objectives:
To perform object oriented design to discover classes and their attributes and methods.
To implement the classes as designed.
In this lab, you will design a set of classes to fulfill a problem description. You will then convert your design into code.
Prelab: No pre-lab or post-lab.
Pair Programming:
Locate your partner and introduce yourself:
Tuesday Lab
Wednesday Lab
Kristen Anderson
Nick Dragu
Chelsea Bainbridge-Donner
Jin Feng Liu
Jake Elder
Jeff Young
Catherine Doyle
Ryan Ersland
Jesse Vazquez
John Wilsterman
Corazon Irizarry
Greg Vaughanj
Select one person to start as "driver". This person will type at the keyboard for the first 20 mintues.
Proceed through the process of completing the lab as described below. Be very careful to ensure that every item for both programs is completed.
Swap pairs every 20 minutes.
When you are done, be sure to email a copy of the code to the person whose account you are not working in. In other words, make sure that both partners have a copy of the code.
Part 1: Design
Your first task is to design the classes to support an application. Find several pieces of blank paper to use to sketch out your design. Use the design process and problem description provided below.
Design Process
Using a piece of blank paper, make a list of all of the nouns in the description. You may find it helpful to underline all the nouns in the problem description.
Refine the list from step 1 above to only include classes that are necessary to solve the problem at hand:
Identify all nouns that refer to the same thing. Select a single name for these. Cross out the extraneous nouns and circle the name of the noun that you have chosen to use as a class name.
Identify and eliminate nouns that we do not need to be concerned with in order to solve the problem. These nouns are typically included in the description but do not take action in the problem description nor do they contain or contribute data.
Identify and eliminate (cross out) the nouns that represent objects rather than classes. These are typically proper nouns in the problem domain or nouns that refer to a specific instance of data rather than to the general category of objects.
Identify the nouns that represent simple values that might be stored in a variable and are either associated with a class or can be stored in a simple variable. If the nouns represent data that is associated with a class, identify the class with which the data is associated by drawing an arrow from the noun to the encapsulating class.
Identify the responsibilities of each class. After completing step 2, you should have a minimal set of classes. Using separate pieces of paper, write the name of each class at the top of a sheet of paper. For each class:
Identify the data that the class is responsible for knowing or keeping track of. These become the attributes of the class.
Identify the actions that the class is responsible for doing. The verbs in the problem domain typically represent actions taken by instances of a class. You may find it helpful to circle all of the verbs in the problem description. These actions become the methods of the class.
Organize the data and actions into a UML class diagram for the problem description.
Now that you have a complete set of classes, walk through the execution of a scenario where a kennel, an owner and a dog are created and the owner boards the dog at the kennel. This walk-through should start in a main procedure and you should verbally walk through the actions taken and the methods called. For instance, this would sound something like: "The main method calls the constructor on the XX class to create an instance of XX. Then the main method ..." During this walkthrough you may need to update your class diagram if you find that you have forgotten attributes or methods.
Once you have completed your design, show it to the professor before implementing your classes.
Problem Description
You must develop an application to be used by a boarding kennel. In this application, kennels are places where owners may board their dogs temporarily while they are away on vacation or for work. Owners bring dogs to the kennel for boarding and all interactions with dogs occurs through the customr. Dogs that may be boarded range from Chihuahuas to Bernese Mountain Dogs. In order to board a dog there must be space in the kennel for the dog. When an owner drops their dog off to be boarded, the owner provides their name, address, telephone number where they can be reached in case of emergency and number of days that they will be gone. The owner indicates the dog's name, gender, breed, age, and weight. If there is space available in the kennel, the Doggie Fun kennel boards the dog and prints a charge estimate based on the dog's size (larger dogs are charged more than small ones) which shows the daily rate, total rate charged, tax, and total charge. If there is no space available in the kennel, the application prints a message indicating this.
Part 2: Implement Your Design
For implementation, you may make the following simplifying assumptions:
The kennel can only hold two dogs.
The daily kennel charge is $10.00 per day for dogs weighing less than or equal to 20 pounds and $15.00 per day for dogs weighing over 20 pounds.
The tax is 4% of the total charge.
See the professor for the implementation guidelines hand out. Test your code carefully to make sure that it operates correctly under a variety of test cases. Your code should have good programming style and follow all Java conventions. Don't forget to use constants where appropriate.
You're done!! Don't forget to log out and hand in your printouts to the professor before you leave!!