Draw and annotate a class hierarchy that represents various types of sales transactions in a store (cash, credit, etc.). Show what characteristics would be represented in the various classes of the hierarchy. Explain how polymorphism could play a role in the payment process.

What will be an ideal response?




The abstract method purchase is established in the Sale class, ensuring that child classes will implement it. That way, each class can have a definition of purchase that makes sense for it, as opposed to the computeTax method, which is implemented in Sale and used by all child classes as is. A program that manages the sales transactions as they occur could then conduct the transaction by making a polymorphic call to purchase no matter what the transaction type is.

Computer Science & Information Technology

You might also like to view...

The MAX function finds the largest number in a range of numeric cells

Indicate whether the statement is true or false

Computer Science & Information Technology

Technical editors do not specifically address grammatical and spelling errors

Indicate whether the statement is true or false

Computer Science & Information Technology

Cache increases computer speed by the processor checking in faster cache memory for the information it wants before it checks in the slower RAM chips

Indicate whether the statement is true or false

Computer Science & Information Technology

If more than one PSO is linked to a user or group, the PSO that applies is determined by the _____________ attribute

a. Password rank b. Precedence c. Domain d. Organizational

Computer Science & Information Technology