Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

quickly please 1. Create a new Java project. Name it lab-02. 2. Add the following classes (GIVEN IN SEPARATE FILES) to the project: public class

quickly please
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
1. Create a new Java project. Name it lab-02. 2. Add the following classes (GIVEN IN SEPARATE FILES) to the project: public class Location private String city: private String country: public Location(String city, String county) this city city this.country country: 3 public String getcityt) { return city: public void setcity(String city) { this city city: public String getCountry() { return country 3 public void setCountry(String country) { this.country country: Bowride public String toString() { return city +.+ country > public class Room private int number: private int floor: private boolean available; public Roon(int number, int Floor, boolean available) this number number; this.Floor floor; this available available; public int cetNumber() return number: public void setNumber(int number) this number = number: 1 public int petFloor() { return floor public void setFloor(int Floor) this floor floor 0 public boolean Available) return available: public void setAvailable(woolean wilable) this available. Wilable onde public String tostrine) return Strine.format(" Koos Nuber utlodet Xd Available10 number, floor, available) Question-1 Hotel Class (80 Points) 1. Create a class named Hotel 2. The class has three attributes as follows: private String name; private Location location; private ArrayList rooms; 3. Create ONE constructor that takes the String name as a parameter. 4. Provided set and get methods for all attributes. (Use Eclipse) > Hotel (default package) o name: String o location: Location o rooms: ArrayList of Hotel(String) getName(): String setName(String) void .getLocation() Location setLocation(Location) void getRooms() ArrayList setRooms(ArrayList):void addRoom(Room) void o reserve Room(int) void getAvailableRooms() ArrayList .getAvailableRoomsCount():int getRoomsCount(); int o floorRooms(int) ArrayList o toString(): String 5. Implement all the methods after the RED line in the class diagram: (NO VALIDATION REQUIRED) 1. public void addRoom(Room r) : Adds a new object to the hotel rooms list. 2. public void reserveRoom(int roomNumber) : Sets the room availability to false. 3. public void releaseRoom(int roomNumber): Sets the room availability to true. 4. public ArrayList getAvailableRooms(): Returns an ArrayList of the available rooms. 5. public int getAvailableRoomsCount(): Returns the number of available rooms in the hotel's room list. 6. public int getRoomsCount(): Returns the number of all hotel rooms. 7. public ArrayList floor Rooms(int floorNumber): Returns an ArrayList of the rooms in a specific floor number. 8. public String toString(): Prints the hotel details without duplicating the code from other classes. Your output should be similar to the following: (Pay attention to all the details in the output). You need to modify to toString method of the Room class to show YES/NO instead of True/False. Hotel: HILTON Address:Doha, Qatar Room Count: 5 (Available:2) Room Number: 123 Room Number: 456 Room Number: 666 Room Number: 333 Room Number: 788 Floor: 4 Floor: 3 Floor: 4 Floor: 4 Floor: 4 Available: NO Available: YES Available: NO Available: YES Available: NO 1. Create a Hotel instance. Set the hotel name to : Java Hotel 2. Create a location object and set it to the hotel location attribute. 3. Create FIVE different room with different numbers, floors, and availability. 4. Add all the rooms to the hotel list. 5. Reserve two rooms. 6. Release one room. 7. Print the hotel

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

Database Administrator Limited Edition

Authors: Martif Way

1st Edition

B0CGG89N8Z

More Books

Students also viewed these Databases questions

Question

=+LO 12-1 Understand the basic forms of power.

Answered: 1 week ago