Lab 4: C++ Classes - Garage

Copyright RIT 6/16/2000
$Id: writeup.xml,v 1.23 2011/10/07 00:03:46 cs4 Exp $


Goal

In this lab you will implement a simple class and a stack-like data structure in C++ using multiple classes.


Team Setup

You are to work on this lab completely on your own.

Pre - Lab Work

  1. Review the documentation for the classes you will write. http://www.cs.rit.edu/~cs4/Labs/lab04/html/annotated.html

  2. Review the documentation for the vector class.

  3. Answer the questions below.

There are questions you must answer before you come to lab. You can do this in one of two ways:

In either case, you must bring a hard copy of the questions and their answers to lab with you.

Question #1:

Which methods of the Car class are const methods? What does const-ness mean in terms of implementation?

Question #2:

Write both the constructors for the Car class, using sub-object construction (AKA initializer lists) for all instance variables.

Question #3:

Given an STL vector named data, write two different ways that you can access its fourth element. Explain one important difference in the effects of these two options.

In-Lab Activities

Activity #1

Study the documentation for the Garage and Car classes to understand how they should work. You will write all the code from scratch, and it must match the provided documentation exactly.

To implement the storage in the Garage class, you must use an STL vector that holds Car objects. You may not use a native array or any other collection class for the Garage storage.

If a method has a documented pre-condition or post-condition, you must use an assertion statement at the start of the method to verify the pre-condition or at the end of the method to verify the post-condition.

You should write a main program to test the functionality of each of the classes and methods you write. Although you do not submit your testing program, you must think carefully about the cases your main tester program must test. When you submit your classes, they will be tested, and you will not see the results.

Your coding style will be graded for this submission. Make sure that you fully document your header files using the required 'docstring' comment blocks from the C++ coding standards found in: http://www.cs.rit.edu/~cs4/standards.html. (You have 2 primary choices for docstring styles: javadoc or C# triple-slash formatting.)

How To Submit

Submit your solution with the command:

try cs4-grd lab4-1 Car.h Car.cpp Garage.h Garage.cpp


Grade Computation

Grade Breakdown: