Answered step by step
Verified Expert Solution
Link Copied!

Question

00
1 Approved Answer

Part I) An appliance object has four attributes, a type (String), a brand (String), a serial number (long), and a price (double). The type of

image text in transcribed

image text in transcribed

Part I) An appliance object has four attributes, a type (String), a brand (String), a serial number (long), and a price (double). The type of an appliance can be any of the following: Fridge, Air Conditioner, Washer, Dryer, Freezer, Stove, Dishwasher, Water Heaters, and Microwave. The brand indicates the vendor/manufacturer of the appliance (such as LG, Samsung, Bosch, etc.), and can be any string. The serial number represents the serial number of the appliance, and must be unique. For simplicity, we assume that the serial numbers start at 1000000 and it is common/shared among all different brands and types (for example, if the creation of objects starts by a Washer created by Maytag, then it will be assigned serial number 1000000. If a Microwave by Breville is created next, then it will be assigned serial number 1000001, and so on afterwards). The price of an appliance cannot be less than 1$. (Hint: Static You are allowed to add other attributes to the class.) For this part, you are required to design and implement the Appliance class according to the following specifications: Upon the creation of an appliance object, the object must immediately be initialized with valid values; that is type, brand, serial number and price. (Hint: Constructors.) The design should allow enough flexibility so that the value of any of these attributes can be modified later on (with the exception of the serial number, which can never be changed once assigned). For example, it should be possible to create an appliance object with a given price then change its price later on. Notice that changes to brand or type is allowed (although this is unusual in reality!). The design should also allow the user to obtain the value of any of the attributes. (Hint: Accessors & Mutators.) The design should allow all information of an object to be displayed at once through the utilization of System.out.print() method. (Hint: toString() method) It is required to know how many appliance objects have been created. For that, you need to add a method, called findNumberOfCreatedAppliances(), to the class. This method must return the number of created appliance objects prior to the time this method is called. The method would simply return 0 if no appliances have been created by the time the method is called. It is required to compare two Appliance objects for equality. Two appliances are considered equal if they have the same brand, type and price. (Hint: equals() method) It is required to display any Appliance object (all info of that object) using System.out.println(() method. (Hint: toSting() method)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered 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

Students also viewed these Databases questions