[SOLVED] COSC6000-Homework 6

15.99 $

Programming resource
Digital learning resource
Category:
✓ Practical programming resource
✓ Suitable for guided study and reference
✓ Tutor guidance available when needed

Description

Rate this product

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

you may define private member functions. (helper functions)

Resource details

Understand the Task Before You Use the Resource

Review the requirements, identify the programming concepts involved, study the implementation and test your understanding with your own examples and modifications.