Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

reate a class named Blanket with fields for a Blanket's size ( size ) , color ( color ) , material ( material ) rice

reate a class named Blanket with fields for a Blanket's size (size), color (color), material (material) rice (price).
nclude a constructor that sets default values for the fields as twin, white, cotton, and $30.00.
Include set and get methods for each of the first three fields. The method that sets size adds $10 to the price for a double blanket, $25 for a queen blanket, and $40 for a king.
info> There should be four acceptable sizes: twin, double, queen, and king.
The method that sets the material adds $20 to the price for wool and $45 to the price for cashmere. In , words, the price for a kirig-sized cashmere blanket is $115. Whenever the size or material is invalid, rese blanket to the default values.
info> There should be three acceptable materials: cotton, wool, and cashmere.
Include a toString() method that returns a description of the blanket.
Part B
Create a child class named ElectricBlanket that extends Blanket and includes two additional fields: on the number of heat settings (settings) and one for whether the ElectricBlanket has an automatic sh feature (hasAutoShutoff). Default values are 1 for settings and false for hasAutoShutoff.
Include get and set methods for the fields. Do not allow the number of settings to be fewer than one or than five; if it is, use the default setting of 1. Add a $5.75 premium to the price if the blanket has the autor shutoff feature.
Also include a toString() method that calls the parent class toString() method and combines the retL value with data about the new fields to return a comolete describtion of features.
image text in transcribed

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_2

Step: 3

blur-text-image_3

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

More Books

Students also viewed these Databases questions

Question

Identify and control your anxieties

Answered: 1 week ago

Question

Understanding and Addressing Anxiety

Answered: 1 week ago