Study the given hierarchical class diagram and additional information, and answer the questions that follow:
Sale
|
Company: string
unitPrice: double
qty: int
salesAmt: double
|
Sale(string, double, int);
getCompany():string;
getUnitPrice():double;
getQty():int;
getSalesAmt():double;
computeRevenue():double;
|
HardwareSale
|
installFee: double
|
hWSale(string, double, int, double)
computeRevenue():double
|
Sale(string, double, int);
|
Constructor that initializes the respective data members to the pass in values. salesAmt is set to 0.
|
getCompany():string;
|
Returns the company
|
getUnitPrice():double;
|
Returns the unit price
|
getQty():int;
|
Returns the quantity
|
getSalesAmt():double;
|
Returns the sales amount
|
computeRevenue():double;
|
Sets sales amount = unit price * quantity. Returns this computed value.
|
hWSale(string, double, int, double)
|
Invokes the base class constructor and sets install fees accordingly
|
computeRevenue():double
|
Sets sales amount = unit price * quantity + install fees
|
(a) Write the class specification and code to implement the following classes, fulfilling the given requirements:
(i) Sale (base class)
(ii) HardwareSale(derived class)