Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

XYZ Company uses the service provided by an obtained object of Utility class to sort elements of type T. The default constructor of the Utility

XYZ Company uses the service provided by an obtained object of Utility class to sort elements of type T. The default constructor of the Utility class will set the private string attribute sortName to be bubblesort algorithm. For other sorting algorithms like quicksort, the constructor Utility(string sortName) needs to be used instead. Note that new sorting algorithms are likely to be added in the future. The Utility class has two methods. One method can return the sortName and the other method List sort(List data) can sort objects of type T ascendingly based on the price of T. Besides the price attribute, class T has two other attributes: ID and name. All except ID are accessible through the individual get/set methods. The ID is expected to be fixed once assigned.

The two current sorting algorithms cannot print the sorted result but only return the sorted list for objects of type T. The XYZ Company now demands this printing feature to have add-ons for the two existing algorithms and possibly new algorithms as well. To prevent troubles, the goal is not to modify the algorithm code, not to change the relationship between XYZ, and not to update the existing Utility class. Moreover, the add-ons for each algorithm should allow the printing features in its own way. The bubblesort will print ID, name and price on a row in order, while the quicksort will print price, name and then ID in a different order.

(5 pts) There are three necessary interfaces and classes: XYZ, Utility, and ProductIF. Feel free to add more, so that a suitable Utility object can be used by XYZ to meet the sorting needs. Show your UML class diagram design and ensure attributes, methods, visibility, arguments and relationships are correctly included.

(5 pts) Implement code in C#. Demonstrate the execution for the following scenarios. XYZ gets a suitable Utility object. XYZ utilizes that object to run quicksort for a list of four desks (Desk for type T) with prices like 20.30, 15.25, 25.13, and 5.85. Hint: IComparable interface may be useful. Feel free to take advantage of already developed sorting algorithms.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Data Management Databases And Organizations

Authors: Richard T. Watson

2nd Edition

0471180742, 978-0471180746

More Books

Students also viewed these Databases questions

Question

=+What is the nature of the plant or site-level role of unions?

Answered: 1 week ago