Saint Louis University |
Computer Science 180
|
Dept. of Math & Computer Science |
Please see the general programming webpage for details about the programming environment for this course, guidelines for programming style, and details on electronic submission of assignments.
The files you need for this assignment can be downloaded here.
For this assignment, you must work individually in regard to the design and implementation of your project.
Please make sure you adhere to the policies on academic integrity in this regard.
This assignment is designed to be a bit of a puzzle. In the end, it will take relatively few lines of actual code. The key will be to successfully settle upon a those lines of code. The topic we wish to explore are the subtleties involve the life cycle of an object: how and when objects are constructed and destroyed; the distinctions between objects, references to objects, and pointer variables; the ways in which information is passed to and from functions. For preparation, we strongly suggest that you review all aspects of the object demo which we have discussed in class.
This assignment builds upon the following model for automobiles. We will be providing a complete implementation of a simple Car class. However we have carefully tailed the access control for that class in the following way:
A member of the general public (which we will model as the main routine) has very limited access to cars. The only two functions which can be directly invoke by the public are:
The typical output operator (<<) can be used to print a description of an existing car.
A method with signature
void breakIt()which breaks an existing car (drive safely!)
Note well that a member of the general public cannot directly construct a car.
Another class, Dealer, will be used to represent a typical car dealership. This class will act as an intermediary between the public customers and the underlying car manufacturer.
In particular, the Dealer has been granted two forms of access which were not available to the general public.
A Dealer may call the constructor for the Car class to cause a new car to be created. Specifically, the signature for the constructor is
Car(string c, int doors)where c specifies the color of the car (e.g. "red") and doors specifies the number of doors (e.g. 2-door, 4-door).
A method with signature
void fixIt()which fixes the car upon which it is invoked.
No one (not even a dealer) is allowed to 'clone' a car. That is, we have intentionally disabled both the copy constructor for the Car class as well as the typical semantics of the assignment operator (=). Any direct or indirect use of such syntax will result in a car which is tagged as 'invalid'.
Car class
We are providing you with two files, Car.h and Car.cpp, which
fully implement this class. You are not to modify these
files (in fact, you do not even need to read them).
Dealer class
Though we provide you with an outline, in files Dealer.h and
Dealer.cpp, your main task is to design and implement two public
functions which are to be supported by the Dealer class, and
used by the general public.
orderCar
This function is what the public will use when they want
to purchase a car. It should take two parameters,
specifying the desired color and the desired number of
doors.
repairCar
This function should take one parameter which is used to
specify the particular car in question. The dealer will
be responsible for seeing that the car is fixed.
You may notice that we have been intentionally vague as to the precise signature of these two methods. It is up to you to decide upon the precise means to accomplish the desired goals. In fact this is the biggest challenge in the assignment.
main routine
You are to demonstrate the use of your Dealer class by the
general public as follows. Your main routine should follow a
script with the following steps.
Instantiate a Dealer object which you can then use for remaining interactions.
You should order two separate cars from the dealer, one a blue 4-door (the family car), and the other a red 2-door (the convertible). Output the description of each car to demonstrate that they have been properly created.
Once you have your two cars, you should break one of the two. After doing so, again output a description of each car to demonstrate that one is broken and the other is not.
Have the dealer repair the broken car. After this is complete, again output a description of each car to demonstrate the progress.
Please see details regarding the submission process from the general programming web page, as well as a discussion of the late policy.
You should submit four files:
Test.cpp - The file which includes the main routine.
Dealer.h - The revised definition of a Dealer class.
Dealer.cpp - The revised implementation of Dealer functions.
readme - In your own words, please explain what decisions led you to the final choice of signatures for the orderCar and repairCar functions.
You may add any further comments you wish to make to the grader.
Notice that you need not submit the Car class files or the makefile, as they are presumed to be unchanged from those we originally provided.
We will provide you with an initial set of files for your use.
TBA