Question: Create a Mattress class should have fields for size (king, queen, twin), manufacturer, and price, and a constructor should set default values for each. Write

Create a Mattress class should have fields for size (king, queen, twin), manufacturer, and price, and a constructor should set default values for each. Write set methods only for size and manufacturer. The set method for size adds $200 for king or $100 for queen. Add a toString() method that returns the data from all of the fields.

A child class named AdjustableMattress extends Mattress and adds a field for adjustment type (air or mechanical), with air being the default. Include a get and set method for this field, adding $400 for air and $500 for mechanical. Implement a constructor that accepts all fields and calls the Mattress constructor. A toString() method should call the parent class toString() and add to it the adjustment type.

An application named MattressDemo should thoroughly demonstrate the functionality of both classes.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!