Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a class definition for a subclass suite92. A suite92 is a hotelroom92, but use the fact that a suite92 is a hotelroom92 with extras

Write a class definition for a subclass suite92. A suite92 "is a" hotelroom92, but use the fact that a suite92 is a hotelroom92 with extras (that cost $30.00 more). The extra $30.00 is the only difference you have to code. Write the constructor for suite92, calling the hotelroom92 constructor to initialize the two inherited data fields and then you add the $30 on to the roomrate. The rest of the suite92 class would be the same as a hotelroom92. The hotelroom92 class definition and the main ex92c for the hotelroom92 are attached. 2c. Add a suite92 object to main ex92c with room number 475 by running the constructor. Use the inherited get methods to print the room number and room rate (like the hotelroom92 object).

Hotelroom class:

public class hotelroom92 { protected int roomnum; protected double roomrate; public hotelroom92(int n) { roomnum = n; if (roomnum <= 299) roomrate = 69.95; else roomrate = 89.95; } public int getroomnum() { return roomnum; } public double getroomrate() { return roomrate; } } 

Hotel Room main method:

public class ex92c { public static void main(String[] args) { hotelroom92 h = new hotelroom92(375); System.out.println("Hotel Room " + h.getroomnum() + " " + h.getroomrate()); } } 

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

Databases Demystified

Authors: Andrew Oppel

1st Edition

0072253649, 9780072253641

More Books

Students also viewed these Databases questions

Question

What is the purpose of the Salary Structure Table?

Answered: 1 week ago

Question

What is the scope and use of a Job Family Table?

Answered: 1 week ago