Question 4: Write the source code of the classes ReportCurrentRevenue and ReportPastIncome. The ReportCurrentRevenue class is responsible from calculating the current amount of money to be gained if all the guests would leave from the hotel. The ReportPastIncome class is responsible from calculating the money gained so far from the previous visits of guests. Class Hotel will create one instance of this class and execute it in multithreaded fashion in its report method. You will code Hotel.report in the next question. Question 5: Write the source code of only the following methods of the class Hotel. The explanations of the methods you need to code are given below. Don’t forget to address the multithreading issues when coding. report: The details of this method are given in Question 4. restore: This method loads the Hashtable members and LinkedList visits from the path given by the fileName parameter. However, if there are ongoing multithreaded operations, it must first wait them to be finished. findRoomNrOfGuest: This method returns the room number of a guest whose name is given by the method parameter. It returns 0 if no such guest e

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
100%

[JAVA]

Question 4: Write the source code of the classes ReportCurrentRevenue and ReportPastIncome. The ReportCurrentRevenue class is responsible from calculating the current amount of money to be gained if all the guests would leave from the hotel. The ReportPastIncome class is responsible from calculating the money gained so far from the previous visits of guests. Class Hotel will create one instance of this class and execute it in multithreaded fashion in its report method. You will code Hotel.report in the next question.

Question 5: Write the source code of only the following methods of the class Hotel. The explanations of the methods you need to code are given below. Don’t forget to address the multithreading issues when coding.

  • report: The details of this method are given in Question 4.
  • restore: This method loads the Hashtable members and LinkedList visits from the path given by the fileName parameter. However, if there are ongoing multithreaded operations, it must first wait them to be finished.
  • findRoomNrOfGuest: This method returns the room number of a guest whose name is given by the method parameter. It returns 0 if no such guest exists.
Hotel
ReportPastincome
|- rooms : Hashtable<Integer,Room>
|- visits : LinkedList<Visit>
|- pool : ExecutorService
- addRoom( Room)
- addRoom( roomNr: int, capacity : int, rate : double )
- searchGuest( name : String ): Guest
|- newArrivalToRoom( aGuest: Guest, roomNr: int )
- addGuestToRoom( aGuest: Guest, roomNr: int)
- findRoomNrOfGuest( name : String): int
|- emptyRoom( roomNr: int )
|- report()
- backup( fileName : String )
|- restore( fileName : String )
ReportCurrentRevenue
1
checked
CriticalException
NonCriticalException
unchecked
1
«Abstract»
Room
Person
Visit
|- roomNr: int {final}
- maxRoomCapacity : int {final, static}
|- dailyRate : double
|- guests : LinkedList<Guest>
-v: Visit
+ Room(roomNr: int , capacity : int, dailyRate : double )
setCapacity( int )
+ setDailyRate( double )
+ addGuest( Guest)
+ emptyRoom( ): Visit
+ searchGuest( name : String): Guest
+ toString(): String
getGuestNames(): String
+ getVisit( ) : Visit
|- name, address, phoneNr: String
+ Person( name : String, nationallD: int)
-from, to : java.util.Date
guestNames : String
totalPrice : double
+ Visit( from : Date, room: Room)
+ endVisit( )
getTotalPrice(): double
+ getCurrentRevenue( ): double
- getVisitDurationInDays( begin, end : Date ): long
0.1
Employee
Guest
|- emplD : int {final}
|- enlisted : java.util.Date
Transcribed Image Text:Hotel ReportPastincome |- rooms : Hashtable<Integer,Room> |- visits : LinkedList<Visit> |- pool : ExecutorService - addRoom( Room) - addRoom( roomNr: int, capacity : int, rate : double ) - searchGuest( name : String ): Guest |- newArrivalToRoom( aGuest: Guest, roomNr: int ) - addGuestToRoom( aGuest: Guest, roomNr: int) - findRoomNrOfGuest( name : String): int |- emptyRoom( roomNr: int ) |- report() - backup( fileName : String ) |- restore( fileName : String ) ReportCurrentRevenue 1 checked CriticalException NonCriticalException unchecked 1 «Abstract» Room Person Visit |- roomNr: int {final} - maxRoomCapacity : int {final, static} |- dailyRate : double |- guests : LinkedList<Guest> -v: Visit + Room(roomNr: int , capacity : int, dailyRate : double ) setCapacity( int ) + setDailyRate( double ) + addGuest( Guest) + emptyRoom( ): Visit + searchGuest( name : String): Guest + toString(): String getGuestNames(): String + getVisit( ) : Visit |- name, address, phoneNr: String + Person( name : String, nationallD: int) -from, to : java.util.Date guestNames : String totalPrice : double + Visit( from : Date, room: Room) + endVisit( ) getTotalPrice(): double + getCurrentRevenue( ): double - getVisitDurationInDays( begin, end : Date ): long 0.1 Employee Guest |- emplD : int {final} |- enlisted : java.util.Date
:Hotel
:Room
V: Visit
quests
emptyRoom( )
endvisit( )
to = new Date()
getDailyRate( )
r calculate how many days
have been passed /
rate
totalPrice = days * rate
getGuestNames( )
names
guestNames = names
new()
Transcribed Image Text::Hotel :Room V: Visit quests emptyRoom( ) endvisit( ) to = new Date() getDailyRate( ) r calculate how many days have been passed / rate totalPrice = days * rate getGuestNames( ) names guestNames = names new()
Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Concept of pointer parameter
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education