Computer Science 210 Lab 3: Linked Lists
Due: September 29, 1998

Objectives and Overview: In class we introduced the class type Currency. In this lab you will extend that class in order to get experience with the management of classes.

Part 1 - Extend the Currency Class

Start CodeWarrior and create a new project called Lab3.µ on the desktop. Copy into the project folder the curr1.cpp program file from the CS210 (Chown) folder and add it to your project. In addition copy the file curr1.h to your project foler.

Extend the class Currency of this program by adding the following public member functions:

Input() inputs a currency value from the standard input stream and assigns it to the invoking object.

Subtract(x) subtracts the value of the currency object x from that of the invoking object and returns the result.

Percent(x) returns a currency object whose value is x percent of the value of the invoking object. x is a floating-point number.

Multiply(x) returns the currency object that results from multiplying the invoking object and the floating-point number x.

Divide(x) returns the currency object that results from dividing the invoking object by the floating-point number x.

Implement all member functions and test their correctness using suitable data.

Part 2 - Overloading

Replace the two Set functions by overloading the assignment operator =. An overload of the type operator=(int x) that assigns an integer to an object of type Currency should replace the first Set function. x represents the sign, dollar amount, and cents rolled into a single integer. An overload of the type operator=(float x) should replace the second Set function. Finally, get rid of the Add function and rewrite the overloaded + operator to work without Add.

Lab 3 Deliverables:

Submit your C++ program from this lab by dragging it to the Drop Box folder.

Don't forget to rename your program before you drop it into the drop box! Eg. Currency.Chown.cpp

Also, hand in a hard copy listing of your program