+ 1

Design a Java Class Which represents a room

The Room Class will have three fields RoomNumber, RoomType, RoomSize. there will be two constructors. for each field provide get and set methods. also, provide a display method which outputs the values of all fields can someone help with this? I've done the get and set methods not sure what is meant by display the second part of the question is extend the room class to represent a hotel room subclass is to have extra fields for the number of people per room whether it is an ensuite room, the nightly rate for the room the name of the person who has booked the room if the room has not been booked then this field is set to "not Booked" for each field provide get and set methods also, provide a method to book the room Write a control program which creates three instances of the hotel room class and outputs the name of the cheapest room and allows the user to book it. just looking for some tips or advice on this exam question very new to java

30th Dec 2017, 2:50 PM
Martin Toomey
Martin Toomey - avatar
5 Respuestas
+ 16
by display , it means u need to show the output on the screen , u need to create a class named "room" make different object (ie , different types of rooms) the instance member variables must be room no.,room type,room size ... they will be non-static as are associated with the objects //make constructructor , to initialize these instance member variables for each object ... //give it a try ☺
30th Dec 2017, 5:46 PM
Gaurav Agrawal
Gaurav Agrawal - avatar
+ 1
A display method is the one which helps to display values of all fields. You can code it like this: public void displayRoom() { System.out.println("Room no " + roomNumber + ", type: " + roomType + ", size: " + roomSize + "."); }
30th Dec 2017, 3:56 PM
Al Toe
+ 1
No it's an exam question from a previous year no code that is the entire question.
30th Dec 2017, 5:29 PM
Martin Toomey
Martin Toomey - avatar
0
hey, guys so I need a little help here is my code for the hotel room think I've filled in all the expected criteria. I'm having issues with the other parts the hotel room and the control program public class TheRoom { public int roomNumber ; public String roomType ; public int roomSize; public static void main(String[] args) { // TODO Auto-generated method stub } public int getRoomNumber() { return roomNumber; } public void setRoomNumber(int roomNumber) { this.roomNumber = roomNumber; } public String getRoomType() { return roomType; } public void setRoomType(String roomType) { this.roomType = roomType; } public int getRoomSize() { return roomSize; } public void setRoomSize(int roomSize) { this.roomSize = roomSize; } public void displayRoom() { System.out.println("Room Number: " + roomNumber + ", type: " + roomType + ", size: " + roomSize + "."); } } public class HotelRoom extends TheRoom{ public String guestName; private int roomGuests; private boolean ensuite; private int roomRate; public HotelRoom(int roomNumber, int roomSize, String roomType) { } private String getGuestName() { return guestName; } private void setGuestName(String guestName) { this.guestName = guestName; } private int getRoomGuests() { return roomGuests; } private void setRoomGuests(int roomGuests) { this.roomGuests = roomGuests; } private boolean getEnsuite() { return ensuite; } private void setEnsuite(boolean ensuite) { this.ensuite = ensuite; } private int getRoomRate() { return roomRate; } private void setRoomRate(int roomRate) { this.roomRate = roomRate; } public static void main(String[] args) { @override public void displayRoom() { System.out.println("Guests Name: " + guestName + ", Amount of people staying: " + roomGuests + ", ensuite " + ensuite + "."); } } } any help greatly appreciated!
31st Dec 2017, 11:59 AM
Martin Toomey
Martin Toomey - avatar
0
Define a class called Room with the following attributes: length, height, wall area, breadth and floor Area. Define a suitable constructor for this class and a method to display the details of the room.
10th Jan 2023, 9:44 AM
JESUS RANJAN 21215402
JESUS RANJAN 21215402 - avatar