Programming Assignment #1

 

CS 202 Programming Systems

Winter 2006

 

 

 

 

 

The Application

You have been hired to re-write the software used by the CS Humane Society which finds new homes for dogs and cats. Animals enter the system through donations, as strays, or as part of rescue efforts. Donated animals come with information about: age, breed, owners (full name, address, and phone number), reason for the donation, medical background, and previous veterinarian. Strays only come with information about where they were found (street, city, state); if someone found the stray animals, then information is kept on how to contact them in the future (full name, address, and phone number). Rescued animals come with information about where they were rescued from (street, city, state), possibly the name of the owners (if known), and a reason for the rescue (e.g., natural disaster).

 

Animals can then be adopted or fostered. Adoption means that the animals have a 30 day trial period at a new home, where the Society must keep track of the name, address, and phone number of where they are going, along with information regarding the rest of their animals. Fostered animals mean that the animals are only going to this location until they can be adopted. So,  the animals fostered remain in the “active” list of animals, even though they are no longer living at the shelter.

 

The Shelter is interested in being able to add new animals to the system, adopt or foster animals, and to find out what animals are actively available to be fostered and how long each animal has been in the shelter.

 

You have the flexibility to add more functionality as necessary. If it isn’t written in this assignment – you have the opportunity to make your own decisions!

 

Building a Program

The most important part of this assignment is to implement a set of classes using object oriented programming with a single inheritance hierarchy. The best way to do this, is to design your application first without thinking too much about the data structure – make the application Object Oriented – and then tie in the data structure as necessary. Unlike CS163, we are NOT doing data abstraction here. Therefore, spend some time with this application. You can add features to it as needed. Find all of the nouns. Examine if those nouns make sense as a class. Look at how classes relate to one another. This is the first step. Of course, not every noun should be a class….but it is a place to start!

 

You should think about how to use hierarchy in this design and OOP.

 

Use of Advanced Data Structures

One of the data structures used in this assignment must be  a Balanced tree. You can implement any algorithm that makes sense to you – but it must be your own code! You can be creative about deletions – such as marking nodes for later use rather than re-balancing.

 

Also, modify the data structure in such a way as to quickly allow all of the strays, rescued animals or fostered animals to be quickly found. You might consider using a thread through the tree to allow for this. Or, use another data structure of pointers. The only restriction here is that you cannot duplicate the memory for the various animals!

 

Requirements

1)      Your primary job is to implement an application using. This means you are to create a single inheritance hierarchy and strive for the re-use of your classes.

2)      IMPORTANT: you are not allowed to have public data members this term in structs OR in classes. All data members must be private or protected. There should be no friends in this project!

3)      You may not duplicate the data. You will need to work on the design to keep this efficient and object oriented at the same time.

4)      You will be graded on your use of memory and the underlying efficiency of your design. Strive for an elegant OOP solution – although don’t wait to start (at least on your design)!

5)      Each node’s  array of characters must be dynamically allocated at run time using new (and don’t forget to deallocate it later!). Do not use statically allocated arrays in your nodes!

6)      Realize that you are not allowed to use the string class in this assignment.

7)      Use modular design, separating the .h files from the .cpp files. Remember, .h files should contain the class header and any necessary prototypes. The .cpp files should contain function definitions. Never "#include" .cpp files!

8)      Use the iostream library for all I/O; do not use stdio.h.

9)      Make sure to define a constructor and destructor for your classes. Your destructor must deallocate all dynamically allocated memory.

10)  You are not allowed to use global variables.

11)  You must have a copy constructor. You must also show that you have tested your copy constructor            (***we will talk about this in class ***)

 

 

As part of your design writeup discuss how you used “is a” versus “using” versus “has a” relationships in your design.

 

What to Turn in:

• On the due date, email your shar’d program to: karlaf@cs.pdx.edu

The subject of your email should state: 202-prog1 <your last name> submission

 

      • Also, on the due date turn in a hard copy of your program's source code,  a hard copy of output, a 1-page design consideration write-up, and a 1-page debugger write-up.

 

       INSTRUCTIONS TO EMAIL PROGRAMS: In the subject field of your email, indicate: your last name and the assignment number followed by the word “submission” (this way I will know that the program is being turned in).  When you mail the program, using the following command typed at the UNIX prompt. Do Not Use Pine to accomplish this!

 

   Programs must be emailed using the following syntax:

            type: /bin/sh

            at the prompt type: shar file1.cpp file2.cpp file2.h >prog1

            next, type control-d

 

   To email this archive, type the following. The double quotes are essential!

   mail -s “202 prog1 My Name Submission” karlaf@cs.pdx.edu <prog1

 

      This represents how you might submit the first program that has the filenames: file1.cpp and file2.cpp.

 

       REMINDERS: Every program must have a comment at the beginning with your first and last name, the class (CS202), the name of the file, and the assignment number. This is essential!