CprS 157 Schedule
CprS 157 Class 20
CprS 157 Class 22

Object-Oriented Software Development
Chapter 14 - Class 21





Reading Some Sample Programs


The principal raison d'etre of C++ is to support object-oriented programming. Today's readings illustrate how C++ classes encapsulate the data structures and operations necessary to implement abstract datatypes. Increasingly sophisticated abstract datatypes are implemented as derived classes of more fundamental datatypes. The first project constructs the Time class, which implements the conventional notion of clock time, eg. 9:32 AM, and some standard operations involving time. The second project extends the notion of time to include time zones, such as EST, CST, MST, and PST. This is easily achieved by creating the class ExtTime which inherits from Time and adds to it support for the notion of time zones. We then construct the client class TimeCard, which models the use of a punch-in-and-out timecard system, such as you can see for university employees in the basement of Carnegie. Finally, we model a timecard system for a group of employees with the class TimeCardList. The PunchIn program illustrates the entire system at work.


// SPECIFICATION FILE (time.h)
// This file gives the specification of a Time abstract data type


// IMPLEMENTATION FILE (time.cpp)
// This file implements the Time class member functions


// TestTime program (testTime.cpp)
// This is a very simple client of the Time class



// SPECIFICATION FILE (exttime.h)
// This file gives the specification of an ExtTime abstract data
// type. The Time class is a public base class of ExtTime, so
// public operations of Time are also public operations of ExtTime.


// IMPLEMENTATION FILE (exttime.cpp)
// This file implements the ExtTime member functions.
// The Time class is a public base class of ExtTime


// TestExtTime program (testExtTime.cpp)
// This is a very simple client of the ExtTime class



// SPECIFICATION FILE (timecard.h)
// This file gives the specification of a TimeCard ADT


// IMPLEMENTATION FILE (timecard.cpp)
// This file implements the TimeCard class member functions



// SPECIFICATION FILE (tclist.h)
// This file gives the specification of TimeCardList, an ADT for a
// list of TimeCard objects.


// IMPLEMENTATION FILE (tclist.cpp)
// This file implements the TimeCardList class member functions.
// List representation: an array of TimeCard objects and an
// integer variable giving the current length of the list



// PunchIn program (PunchIn.cpp)
// A data file contains time cards for employees who have punched
// in for work. This program reads in the time cards from the
// input file, then reads employee ID numbers from the standard
// input. For each ID number, the program looks up the employee's
// punch-in time and displays it to the user


 
 

Programming Exercises

  Solve these exercises in class, to your own satisfaction. If called for, create the appropriate data files and test your program on your data. Demonstrate your solutions to the instructor or to the class TA. There is nothing to hand in from this activity.
 
 

Second Programming Project: Video Inventory

 

Videos are everywhere! Just go over to the library and watch them displace more and more walls of books before your very eyes. Videos have even risen to the level of characterizing an entire generation: the MTV generation. Well then, it was only to be expected that programmers would rise to the challenge and put their computers to work managing these fertile new resources. Our next, and subsequent, programming projects will create the software resources necessary to manage a video store. The first segment of this project models videos themselves, and inventories of videos. A continuation of this project will model customers and the operations of the store.

We will take as our specification of the problem to be solved, our text's Programming Problems 14.1 and 14.2, pages 863-864 (video inventory). This programming project asks for two components: (1) a design of your algorithms to solve the problem, such as our authors have been systematically constructing for their case studies, and (2) a complete and correct implementation of your algorithms in C++. The algorithm design consists of two parts: (1.a) a hierarchical chart showing the structure of the computation, and (1.b) descriptions of the contents of the various modules appearing in your hierarchical chart. This project calls for a careful mix of strict dedication to the problem specification contained in the description of the programming problem, and a programmer's software design freedom of choices in setting up the abstract datatypes to support that project.

Place an electronic copy of your work into the CS157 drop box before class time, 9:30:00 AM, next Tuesday, 16 November 1999. Personalize the results of your efforts by using the file-naming conventions explained in class. Hand in paper copies of your solutions at the beginning of class, 9:30:00 AM, 16 November. The grader will use the paper copies for recording any comments he may wish to make about your work. Enjoy!