Develop a class called Weight that is an abstract data type (ADT) for an weight.
The complete class will include all the following member functions:
A constructor to set pound and ounce ex. 2lb 12oz can be set as Weight item1(2,12)
If users set the ounce part grater than 15, like Weight item1(2,20), it should be converted to 3lb 4oz.
A constructor to set ounce ex. 36oz can be set as Weight item2(36) It should be converted to 2lb 4oz.
A default constructor (takes no input) that sets 0lb 0oz.
Public member function, get_Pounds() that returns the pound part of weight.
Public member function, get_Ounces() that returns the ounce part of weight.
The return value must be between 0 to 15. Note 16oz=1lb.
Public member function, get_Grams() that returns the weight in grams.
use 1oz=28.35g
A friend function, Weight add(const Weight& w1, const Weight& w1), which adds two Weight objects and returns a new object of Weight that stores the result.
A friend function, comp compare(const Weight& w1, const Weight& w1), which compares two Weight objects and returns comp type (enum type) variable of:
GREATER if w1>w2, LESS if w1<w2, or EQUAL if w1=w2.
comp type is enum type defined by
enum comp{GREATER=1, LESS=1,EQAUL=0} see Link (http://en.cppreference.com/w/cpp/language/enum)
you may define private member functions. (helper functions)
https://tulane.instructure.com/courses/2165899/assignments/13465091 1/2
Output will be:
https://tulane.instructure.com/courses/2165899/assignments/13465091
Reviews
There are no reviews yet.