Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

A. In a hotel, each room has exactly 3-digit id and a positive price. Develop a class in java to represent class Room strictly as

image text in transcribed
A. In a hotel, each room has exactly 3-digit id and a positive price. Develop a class in java to represent class Room strictly as follows: 1. Define the class Room 2. Define price fields to be private and the id to be public. 3. Define the default constructor that sets an object with values id:1 and price:70.5 4. Define a setter method for price (Make sure to not accept negative price) 5. Define a getter method for price. 6. Define the toString method of the class such that it returns a string representing the room. e.ga ID: 412 Price: 80.25 B. Based on the Room class above complete the main method below public class TestProduct public static void main(String[] args) // 1. Create a Room objects r1 with the following values: id is 521 and price 100 1/ 2. Increment the price of r1 by 10. // 3. Change the id of ri to be 140. // 4. Use toString method to print ri id and price

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

Fundamentals Of Database System

Authors: Elmasri Ramez And Navathe Shamkant

7th Edition

978-9332582705

More Books

Students also viewed these Databases questions

Question

Explain the need for remedial basic skills training programs

Answered: 1 week ago