Write a Java class called HotelRoom that represents a hotel room. The class will contain the following attributes:
•RoomNo (int)
•PhoneNumber (string)
•Capacity (int) – Number of people that room can accommodate.
•Grade (int) – Grade of room ranging 1-5, 5 being most valuable.
Your class should have a constructor that takes a single parameter: RoomNo. The necessary accessors (i.e. get methods) and mutators (i.e. set methods) for class variables:
Room number only accessor
Phone number both mutator and accessor
Capacity both mutator and accessor Grade both mutator and accessor
2.Write a Java class called Hotel that represents a hotel. The class will contain the following attributes:
•Name (string)
•ReceptionPhone (string)
•RoomList (ArrayList of HotelRoom's)
hotel class should have a constructor that takes two parameters: Hotel name and reception phone. The necessary accessors (i.e. get methods) and mutators (i.e. set methods) for class variables:
Hotel name only accessor
Reception phone both mutator and accessor
- Hotel class should have a public method addRoom that gets as parameter a Room object, and adds this Room object to RoomList:
public void addRoom(HotelRoom room)
- Hotel class should have a public method getRoomCount that returns the number of rooms in the hotel (i.e. number of elements of RoomList): public static int getRoomCount()
- Hotel class should have a public method getRoom that returns the room from the room list given the index: public static HotelRoom getRoom(int index)
Hotel class should have one public method in addition to the accessors and mutators: public String toString() It returns the information about the hotel rooms in the following format.
ATTENTION: In this class, the toString method only returns the string representation of the rooms in the hotel, not whole information.
3) Write a Java application class that does the following:
•Input a text file name entered by the user from keyboard.
•Create a Hotel object that contains information read from a text file, using the readHotelmethod. Write a private static readHotel method that gets a file name as a parameter, reads the information about the hotel and rooms of the hotel from an input file and returns a Hotel object. In this method, create Hotel and HotelRoom objects as the input file is read, and insert HotelRoom objects to the ArrayList in the hotel object. private static Hotel readHotel(String filename) Format of the input file is assumed to be:
a. The first line is the name of the hotel, b. The second line is the reception phone number of the hotel. Then several times
c.Room no
d.Phone number of rooms, e.The capacity of the room,
3 f.Quality (Grade) of room. Sample input file with two rooms (green text are comments, they do not exist in the actual input file): Examine the provided sample text file hotel.txt.
hotel.txt =
Crappy Hotel
911
101
91101
1
2
102
91102
2
1
103
91103
3
3
201
91201
4
2
202
91202
2
1
301
NoPhone
1
1
Trending nowThis is a popular solution!
Step by stepSolved in 4 steps with 5 images
- Java- Suppose that Vehicle is a class and Car is a new class that extends Vehicle. Write a description of which kind of assignments are permitted between Car and Vehicle variables.arrow_forwardJava Program This assignment requires one project with two classes. Class Employee Class Employee- I will attach the code for this: //Import the required packages. import java.text.DecimalFormat; import java.text.NumberFormat; //Define the employee class. class Employee { //Define the data members. private String id, lastName, firstName; private int salary; //Create the constructor. public Employee(String id, String lastName, String firstName, int salary) { this.id = id; this.lastName = lastName; this.firstName = firstName; this.salary = salary; } //Define the getter methods. public String getId() { return id; } public String getLastName() { return lastName; } public String getFirstName() { return firstName; } public int getSalary() { return salary; } //Define the method to return the employee details. @Override public String toString() { //Use number format and decimal format //to…arrow_forwardWrite a class definition line and a one line docstring for the class Dog. Write an __init__ method for the class Dog that gives each dog its own name and breed. Test this on a successful creation of a Dog object.>>> import dog>>> sugar = dog.Dog('Sugar', 'border collie')>>> sugar.name'Sugar'>>> sugar.breed'border collie' Add a data attribute tricks of type list to each Dog instance and initialize it in __init__ to the empty list. The user does not have to supply a list of tricks when constructing a Dog instance. Make sure that you test this successfully.>>> sugar.tricks[] Write a method teach as part of the class Dog. The method teach should add a passed string parameter to tricks and print a message that the dog knows the trick.>>> sugar.teach('frisbee')Sugar knows frisbeearrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education