Answered step by step
Verified Expert Solution
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 $
Include set and get methods for each of the first three fields. The method that sets size adds $ to the price for a double blanket, $ for a queen blanket, and $ for a king.
info There should be four acceptable sizes: twin, double, queen, and king.
The method that sets the material adds $ to the price for wool and $ to the price for cashmere. In words, the price for a kirigsized cashmere blanket is $ 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 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 Add a $ 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.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started