Software Architecture

A television system has a regular TV class that has a field “-price: int” to store the MSRP, and can be set by the “~setPrice(price: int)” method. It has two subclasses: Smart_TV and UltraHD_TV. The default prices are $200 for TV, $300 for Smart_TV, and $400 for UltraHD_TV. Let the Smart_TV and UltraHD_TV be declared as final, i.e., accepting no subclasses.

There is a Retailer class stored in a different package (or assembly in C#) from that of the three television classes. It has an association link with just the regular TV class and can replenish a television object of those three types through this association relationship. The replenishment is done by the TV’s “+replenishTV(budget: int): TV” method to obtain a TV object. The returned object should have its MSRP closest to and below the budget. For example, budget of $350 will return a Smart_TV of $300. If no TV is available for a low budget, the method returns null. The Retailer can also call the “+getInfo()” method of the returned TV object to invoke all of its get??? methods. The get??? methods include one “~getPrice(): int” to return the MSRP, and a “~getType(): String” method to know the type (Regular, Smart, or UltraHD). A Smart_TV object further has a “~getPowerUsage(): double” method to display 5.5 watts power usage per hour.

Today, two name brands Vizio and Sony are integrated into the same package of the TV system. Both brands have their own regular TV, Smart_TV, and UltraHD_TV. The MSRP of Vizio_TV is $250, Vizio_Smart_TV is $350 and Vizio_UltraHD_TV is $450. Sony_TV is $280, Sony_Smart_TV is $380 and Sony_UltraHD_TV is $480. Besides those get??? methods defined in no brand products, these two brands further have a “~getBrand(): String” method to show the brand. For power consumption, the Vizio_Smart_TV consumes 6.35 watts per hour while the Sony_Smart_TV uses 5.15 watts per hour.

The integration is requested not to modify code of the original three classes. The only association link from the Retailer to only the regular TV class must be maintained. Another request is to ensure that the design achieves the best software reuse for methods and fields. For example, the field “-price: int” and certain getter and setter methods in the TV class should be shared by all other television classes without code duplication.

Draw the UML class diagram for the new system design. (5 pts)

Implement a C# program for the user to input a budget and run the +getInfo() method for the received non-null object. (5 pts)

SAMPLE ASSIGNMENT
Powered by WordPress