Create a class named Blanket with fields for a blanket's size, color, material, and price. Include a constructor that sets default values for the fields as Twin, white, cotton, and $30.00. 1 2 3 Copy Include a set method for each of the first three fields. The method that sets size adds $10 to the base price for a double blanket, $25 for a queen blanket, and $40 for a king. The method that sets the material adds $20 to the price for wool and $45 to the price for cashmere. In other words, the price for a king-sized cashmere blanket is $115. Whenever the size or material is invalid, reset the blanket to the default values. Include a toString() method that returns a description of the blanket. Save the file as Blanket.java. Create a child class named ElectricBlanket that extends Blanket and includes two additional fields: one for the number of heat settings and one for whether the electric blanket has an automatic shutoff feature. Default values are one heat setting and no automatic shutoff. Include get and set methods for the fields. Do not allow the number of settings to be fewer than one or more than five; if it is, use the default setting of 1. Add a $5.75 premium to the price if the blanket has the automatic shutoff feature. Also include a toString() method that calls the parent class toString() method and combines the returned value with data about the new fields to return a complete description of features. Save the file as ElectricBlanket.java. Create an application that declares a blanket of each type and demonstrates how the methods work. Save the file as DemoBlankets.java

EBK JAVA PROGRAMMING
9th Edition
ISBN:9781337671385
Author:FARRELL
Publisher:FARRELL
Chapter11: Advanced Inheritance Concepts
Section: Chapter Questions
Problem 6PE
icon
Related questions
Question
100%

Everything is in the attached picture! Thank you so much!

Create a class named Blanket with fields for a blanket's size, color, material, and price.
Include a constructor that sets default values for the fields as Twin, white, cotton, and $30.00. Copy
1
2
3
Include a set method for each of the first three fields. The method that sets size adds $10 to the base
price for a double blanket, $25 for a queen blanket, and $40 for a king. The method that sets the material
adds $20 to the price for wool and $45 to the price for cashmere. In other words, the price for a king-sized
cashmere blanket is $115. Whenever the size or material is invalid, reset the blanket to the default
values. Include a toString() method that returns a description of the blanket. Save the file
as Blanket.java.
Create a child class named ElectricBlanket that extends Blanket and includes two additional fields: one for the number of heat settings and
one for whether the electric blanket has an automatic shutoff feature. Default values are one heat setting and no automatic shutoff. Include
get and set methods for the fields. Do not allow the number of settings to be fewer than one or more than five; if it is, use the default setting
of 1. Add a $5.75 premium to the price if the blanket has the automatic shutoff feature. Also include a toString() method that calls the parent
class toString() method and combines the returned value with data about the new fields to return a complete description of features. Save
the file as ElectricBlanket.java.
Create an application that declares a blanket of each type and demonstrates how the methods work. Save the file as DemoBlankets.java
Transcribed Image Text:Create a class named Blanket with fields for a blanket's size, color, material, and price. Include a constructor that sets default values for the fields as Twin, white, cotton, and $30.00. Copy 1 2 3 Include a set method for each of the first three fields. The method that sets size adds $10 to the base price for a double blanket, $25 for a queen blanket, and $40 for a king. The method that sets the material adds $20 to the price for wool and $45 to the price for cashmere. In other words, the price for a king-sized cashmere blanket is $115. Whenever the size or material is invalid, reset the blanket to the default values. Include a toString() method that returns a description of the blanket. Save the file as Blanket.java. Create a child class named ElectricBlanket that extends Blanket and includes two additional fields: one for the number of heat settings and one for whether the electric blanket has an automatic shutoff feature. Default values are one heat setting and no automatic shutoff. Include get and set methods for the fields. Do not allow the number of settings to be fewer than one or more than five; if it is, use the default setting of 1. Add a $5.75 premium to the price if the blanket has the automatic shutoff feature. Also include a toString() method that calls the parent class toString() method and combines the returned value with data about the new fields to return a complete description of features. Save the file as ElectricBlanket.java. Create an application that declares a blanket of each type and demonstrates how the methods work. Save the file as DemoBlankets.java
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 5 steps with 1 images

Blurred answer
Knowledge Booster
void method
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781305480537
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage