Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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

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

Recommended Textbook for

More Books

Students also viewed these Databases questions