Reference no: EM13162431
Overview
creating an object-oriented, multiple-file project and class definition
involving the use of static data members, overloaded operations and class friend functions used
to manipulate lengths expressed in the English system of measurements: yards, feet and
inches. It will require you to create a class called Length and exercise the class functions from a
menu-driven main() function.
Requirements
Class Length should have the following data members:
? int yards; //Holds the equivalent number of yards, can be any positive value
? int feet; //Holds the equivalent number of feet between 0 and 2
? int inches; //Holds the equivalent number of inches between 0 and 11
? static int lengthCount; //Holds the current number of Length objects in existence
Class Length should also have the following function members:
? Constructor(s): You need a default constructor (one that takes no parameters) and one
that takes 3 (for inches, feet, yards). You can do this with two separate functions, or a
single function with defaults for everything. The default value for a Length is 0 in all data
members. The constructor should also increment the static variable lengthCount.
? A destructor. This should decrement the static variable lengthCount.
? A display function - to display all data members of a Length object
? Four accessor functions - to access the yards, feet and inches data members, and the
length counter.
? Overloaded operators as member functions for addition (+), and subtraction (-).
? Overloaded operators for comparisons for greater than, less than, and equality (<, >,
==).
? Two overloaded operators as friends: input ( >> ) and output (<<).
? A private member function that converts lengths to "lowest terms," in which the number
of inches is in the range from 0-12 and the number of feet in the range 0-2. (A Length of
5 feet 16 inches 'reduces' to 2 yards, 0 feet, 4 inches, for example.)
The main() driver function is to create an array of at least four objects of class Length and
initialize all data members to default values. The menu portion of main should allow the user to
select any of the following options:
? Display all Length objects' measurements
? Edit a selected Length object. You should use the overloaded operators to display the
current values and to enter the new values for the selected object.
? Add two selected Length objects measurement (the result is a new Length object)
? Subtract a selected Length objects measurement from another (again, the result is a
new Length object.) Your main program is required to ensure that the shorter length is
subtracted from the longer one so the result is always >= 0 and to prevent any negative
results.