Assignment II for Programming and Problem Solving II | CECS 274, Assignments of Computer Science

Material Type: Assignment; Class: Programming & Problem Solving II; Subject: Computer Engr & Computer Sci; University: California State University - Long Beach; Term: Unknown 1989;

Typology: Assignments

Pre 2010

Uploaded on 08/19/2009

koofers-user-3m4-1
koofers-user-3m4-1 🇺🇸

10 documents

1 / 1

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
CECS 274 Programming and Problem Solving II
Assignment 2
Purpose:
To introduce you to the use of C++ classes as abstract data types (ADTs) and make sure you can
use functions, structs and I/O in C++. You must also design and manipulate a simple data
abstraction for representing time on a 24-hour clock.
Problem:
Write a C++ class called clock which implements an ADT for a 24-hour clock.
Design and implement clock so that it represents the time of day. Represent the time as hours,
minutes and seconds on a 24-hour clock. The hours, minutes and seconds are the private data
members of the class that implements the ADT.
Include at least two initialization operations: one that provides a default value for the time, and
another that sets the time to a client-supplied value. These operations are the class’ constructors.
Include the following operations:
setClock -- sets the time
incrSeconds -- increase the present time by a number of seconds
print12hr -- display the time in 12-hour notation
print24hr -- display the time in 24-hour notation
timeDiff -- a friend function that returns the difference in time between two objects of
the type Clock. The parameters to timeDiff will be two objects of type Clock. timeDiff
returns the difference in seconds.
isEarlier -- a friend function that returns the True if the first object of type Clock occurs
before the second object of the type Clock. The parameters to isEarlier will be two
objects of type Clock. isEarlier returns False otherwise.
You will be provided with a main program that tests your package.
Submissions:
Due Wednesday, September 13: Program Specifications and Initial Documentation
Turn in your specifications for a modular design of this program. You should include program
documentation and specifications for each function you will be using. Please see the class
handout on program documentation. Note: Spelling and grammar are important.
Due Wednesday, September 20: Completed C++ Program
Turn in your completed C++ program during lab. You will be asked to demonstrate your
program, and a simple quiz will be given on the basics of the program.
Dr. Tracy Bradley Maples

Partial preview of the text

Download Assignment II for Programming and Problem Solving II | CECS 274 and more Assignments Computer Science in PDF only on Docsity!

CECS 274 Programming and Problem Solving II

Assignment 2

Purpose:

To introduce you to the use of C++ classes as abstract data types (ADTs) and make sure you can use functions, structs and I/O in C++. You must also design and manipulate a simple data abstraction for representing time on a 24-hour clock.

Problem:

Write a C++ class called clock which implements an ADT for a 24-hour clock. Design and implement clock so that it represents the time of day. Represent the time as hours, minutes and seconds on a 24-hour clock. The hours, minutes and seconds are the private data members of the class that implements the ADT. Include at least two initialization operations: one that provides a default value for the time, and another that sets the time to a client-supplied value. These operations are the class’ constructors. Include the following operations:

 setClock -- sets the time

 incrSeconds -- increase the present time by a number of seconds

 print12hr -- display the time in 12-hour notation

 print24hr -- display the time in 24-hour notation

 timeDiff -- a friend function that returns the difference in time between two objects of

the type Clock. The parameters to timeDiff will be two objects of type Clock. timeDiff returns the difference in seconds.

 isEarlier -- a friend function that returns the True if the first object of type Clock occurs

before the second object of the type Clock. The parameters to isEarlier will be two objects of type Clock. isEarlier returns False otherwise. You will be provided with a main program that tests your package.

Submissions:

Due Wednesday, September 13: Program Specifications and Initial Documentation Turn in your specifications for a modular design of this program. You should include program documentation and specifications for each function you will be using. Please see the class handout on program documentation. Note: Spelling and grammar are important. Due Wednesday, September 20: Completed C++ Program Turn in your completed C++ program during lab. You will be asked to demonstrate your program, and a simple quiz will be given on the basics of the program. Dr. Tracy Bradley Maples