CS2005 - D Term, 2004
Lab 1

March 24, 2004



Purpose

To give you experience in writing a client program to test a class implementation.

Problem

For Homework 1, you have been given a header file that defines the class telephoneBook. The header file completely defines the behavior of an object of type telephoneBook through the specification of the pre- and post-conditions of each member function and the prototypes of those functions. Your job is to implement the member functions of the telephoneBook class. How should you proceed?

It helps enormously to have written a client program to test your implementation before tackling the implementation itself. Why? Because in order to write the client, you must thoroughly understand how to use and activate (call) each member function. You must understand each function's inputs and outputs. Armed with that knowledge, the actual implementation of each member function usually turns out to be fairly trivial.

In this lab, you will start with the telephoneBook class's header file. You will create a compilable version of the implementation by defining each telephoneBook member function as a stub. You will then write a client program to make sure you thoroughly understand the usage of each telephoneBook operation.

What you should do...

You may have completed some of the following steps already, as you have been working on Homework 1:
  1. Sign the attendance sheet.

    If you have already turned in HW1 Part1...

    If you have already turned in HW1 Part1, the TA will pre-grade your work. Sign your name on the "Pregrading Signup Sheet" (the TAs will pregrade assignments on a first-come first-served basis). After you have gone over the grading of your assignment with the TA, you are done; you may stay in the lab until the end of the lab period and make corrections to your homework, or you may leave.

    If you are still working on HW1 Part1...

  2. Follow steps (1) - (4) in Part 1 of Homework 1. Ask a TA or SA for help if you get stuck.

  3. Create teletest.cxx (step (5) of the homework) so that the program activates each of the telephoneBook operations as described in the header file comments. You will need to look at telephone.h to make sure that the program uses the correct calling sequence when activating the functions. Compile the client program using the command

    g++ -Wall -c teletest.cxx

  4. Link the telephoneBook class files, the person class files, and the client program together to create an executable test program. The command is

    g++ teletest.o telephone.o person.o

    Execute the program by typing

    a.out

  5. The program produces nonsense for results, of course, because at this point each telephoneBook member function is implemented as a stub. But think of what you've accomplished. You have built a program that compiles and links. You thoroughly understand the purpose of each telephoneBook member function. You know what kinds of parameters to provide for each member function.

  6. If you're running out of time, don't worry. The important part of this lab is that you understand the process involved in developing an implementation. Before you leave, use the turnin command to turn in your '.cxx' files. (Turn your files in even if you haven't finished. You have one more day to complete Part 1 of Homework 1, and you can turn in your completed work again any time before 11:59 tomorrow evening.)

    /cs/bin/turnin submit cs2005 hw1part1 telephone.cxx teletest.cxx
    



Glynis Hamel 2004-03-11