What is wrong with the class name thing

Assignment Help C/C++ Programming
Reference no: EM133682893

Object Oriented Programming Hurdle Task: Semester Test

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.

Task 1
Consider the following UML diagram:

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 order.
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 transaction.
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):
Sales:
Batch sale: #2024x00001, CompSci Books #1, Deep Learning in Python, $67.90 #2, C# in Action, $54.10
#3, Design Patterns, $129.75 Total: $251.75
Batch sale: #2024x00002, Fantasy Books Empty order.
#00-0001, Compilers, $134.60
#10-0003, Hunger Games 1-3, $45.00 #15-0020, Learning Blender, $56.90 Sales total: $488.25
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:

<<abstract>> Thing
_number: String
_name: String
+ Thing(String number, String name)
+ Print() <<abstract>>
+ Total() : Decimal <<abstract>>

+ Number : String <<read-only property>>
+ Name : String <<read-only property>>
Restructure the current solution as follows:
Implement the abstract class Thing.
Change class Batch so that it stores instances of class Thing rather than class Transac- tion.
Make class Batch and class Transaction subclasses of class Thing. Apply the necessary refactoring steps.
Change class Sales to maintain only a single list _orders of Thing objects.
Replace the methods AddBatch and AddTransaction with a single method Add in class
Sales.
Revise the implementation of PrintOrders in class Sales.
Write a simple Main program to demonstrate that your new design works. The Main
program must
Create a Sales object.
Add batch orders to the Sales object.
Add single transaction orders to the Sales object.
Must create one nested batch order.

Add an empty batch order.
Tell PrintOrders to the Sales object. You are required to:
Provide a new UML class diagram for your updated design (it can be drawn by hand).
Write the code for all classes, including the abstract class Thing, and all fields, construc- tors, methods, and properties.
Write a simple Main method as described above.
Take a screenshot of the output of your program.

Task 2

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

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 1.

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 relationship.

Reference no: EM133682893

Questions Cloud

What populations will be negatively impacted : Explain how each policy works e.g., Is it mandatory? Will enforcement be necessary? What populations will be negatively impacted?
Explain aggravating circumstances : Explain Aggravating circumstances? Explain Mitigating circumstances? What are Predisposition reports?
Describe specific items within each impact area : Describe specific items within each impact area that exemplify the changes or actions that may need to be made. Include support from a credible source.
Efforts of both spouses during marriage : A business started by the efforts of both spouses during marriage is CP. Application: W and H opened their law firm in 2005, during marriage
What is wrong with the class name thing : Object Oriented Programming Hurdle Task 1: Semester Test - Demonstrate your understanding of object-oriented programming and the core concepts of object
Principle in williams v roffey bros and nicholls : That Gaffe J had not erred in applying the principle in Williams v Roffey Bros and Nicholls (Contractors) LTD [1991] 1 QB 1.
Economic research and publications department quasi-body : Lima Mataba is a Policy analyst at Zambia Economic Research and Publications department a quasi-body under the Ministry of Commerce.
Describe any difficulties you had in making your choice : Describe any difficulties you had (or are having) in making your choice, and the factors that drove/are driving your decision.
How was the success of the program or policy measured : How was the success of the program or policy measured? How many people were reached by the program or policy selected?

Reviews

len3682893

4/25/2024 10:15:24 PM

hi I need help with object oriented programming assignment in C sharp. only 24 hr left for submission.

Write a Review

C/C++ Programming Questions & Answers

  Write a C program that prints an n by n magic square

Write a C program that prints an n by n "magic square" (a square arrangement of the numbers 1, 2, ..., n2 in which the sums of the rows, columns, and diagonals are all the same). The user will specify the value of n.

  Write a program that is called playing with numbers or

write a program that is called playing with numbers or letters. this program allows a user either to enter a collection

  What is the first line of output when this program is run

What is the first line of output when this program is run? What is the second line of output when this program is run? What is the first line of output when this program is run?

  Design and implement a library system that does the

design and implement a library system that does the following ? takes details of a studentlibrary users first name last

  Output of the given c++ code

What is the output of the given C++ code - You need to find out the output of the given code.

  Use a for loop to generate 100 random numbers.

Use a For Loop to generate 100 random numbers. Determine the most current maximum and minimum number as the random numbers are being generated. This is referred tp as a "running" maximum and minimum. Display the running maximum and minimum values as ..

  Value of x after the following code is executed

What will be the value of x after the following code is executed?int x = 20, y = 30;while (y

  Explain our advocacy evaluation

Weaknesses-lack of calloboration between violence prevention and sexual education programs.explanation for our Advocacy Evaluation

  Implement the account class which contains two private data

The calculateFutureBalance function, which takes annual interest rate and number of years, and then calculates the future balance for the given period.

  Write a program to ask for the chord

With one cut across the middle of a pizza you can cut off half, that is, 50% of the pizza. With one cut at a different place you can cut off.

  What is the maximum total value that will be obtained

Building Projects - A company shall invest in some building projects, so that it is obtaining the maximum total value from them

  Write a method that accepts a string

Write a method that accepts a String object as an argument and displays its contents backward. For instance, if the string argument is "gravity" the method should display - "ytivarg". Demonstrate the method in a program that asks the user to input..

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd