Write My Paper Button

Describe the principle of polymorphism and how and where it is being used in Task What is wrong with the class name Thing? Suggest a better name and explain the rea- soning behind your answer. What i

Assignment Task

Purpose

Demonstrate your understanding of object-oriented programming and the core concepts of object-oriented design.

Task

You must complete two tasks. The first is a coding task, and the second is a series of short answer questions.

1. Sales is a class that contains knowledge of purchase orders that a business has received. There are two types of purchase orders: single transaction orders and batch orders, which the class Sales records separately in two dedicated lists. Batch orders are instances of class Batch and can be added to its corresponding list, _batch_orders, using method AddBatch. Single trans- action orders, on the other hand, are instances of class Transaction and can be added to its corresponding list, _single_orders, using method AddTransaction. All orders can be printed to the console via method PrintOrders.

Class Batch defines three member variables:

number, a string that identifies this order,
name, a string that captures the purpose of this order, and
items, a list of single orders attached to the bulk order. In addition, class Batch defines the methods
Add to add a single order,
Print to print this order, and
Total to return the total sum of this

Finally, class Batch defines two read-only getters to obtain the Number and Name of the order. Class Transaction is similar. Its member variables are:

number, a string that identifies this order,
name, a string that describes the product in this order, and
amount, a decimal value to store the total of the single

Class Transaction defines a Print and a Total method, which print the order and return the amount of this order, respectively. The read-only getters return the Number and Name of a single transaction order.

A sample output of an application implementing the above UML diagram may look like the fol- lowing (result of telling a Sales object to PrintOrders):

You may have noticed a peculiar feature duplication in the design. In addition, batch orders are limited to containing single transaction orders. This is an arbitrary limitation. Batch orders should be able to contain nested batch orders. Consequently, class Batch should allow for both, objects of class Batch and objects of class Transaction, to be stored (i.e., added to _items).

To achieve this, you need to redesign the system. Start with the abstract class Thing as shown in the following UML diagram:

Task 2

Describe the principle of polymorphism and how and where it is being used in Task

What is wrong with the class name Thing? Suggest a better name and explain the rea- soning behind your answer.

What is abstraction and how and where it is being used in Task

Can you think of a scenario or system design that resembles Task 1? Look a the classes and their interaction in Task 1 and identify a real-world system or approach that uses a similar

WhatsApp Widget
GET YOUR PAPER DONE