[JAVA] Answer these questions according to the UML class schema given above. You may need to extract hidden information from the schema and add necessary code. You don’t have to consider...



[JAVA]


Answer these questions according to the UML class schema given above. You may need to extract hidden information from the schema and add necessary code. You don’t have to consider inconsistencies other than the ones explicitly stated in questions. You will be writing some part of hotel management software.


Pay attention to the following details about the program logic when writing your code:



Question 1: Write the source code of classes CriticalException and NonCriticalException.



Question 2: Write the source code of classes Person and Employee.



Question 3: Write the source code of class Room. The details of its methods are as follows:



  • setCapacity: If one attempts to set a negative capacity or a capacity greater than maxRoomCapacity, a CriticalException is generated.

  • setDailyRate: A room’s daily rate must not be changed while there are guests in it. Otherwise, a NonCriticalException is generated.

  • Constructor must use the setter methods described above.

  • addGuest: A guest must not be added multiple times. Otherwise, a CriticalException is generated.

  • emptyRoom: Code it according to the given sequence diagram on the second paper.

  • toString: Returns a String that contains information about the room number, its capacity and its current guests’ names.


Hotel<br>ReportPastincome<br>|- rooms : Hashtable<Integer,Room><br>|- visits : LinkedList<Visit><br>|- pool : ExecutorService<br>- addRoom( Room)<br>- addRoom( roomNr: int, capacity : int, rate : double )<br>- searchGuest( name : String ): Guest<br>|- newArrivalToRoom( aGuest: Guest, roomNr: int )<br>- addGuestToRoom( aGuest: Guest, roomNr: int)<br>- findRoomNrOfGuest( name : String): int<br>|- emptyRoom( roomNr: int )<br>|- report()<br>- backup( fileName : String )<br>|- restore( fileName : String )<br>ReportCurrentRevenue<br>1<br>checked<br>CriticalException<br>NonCriticalException<br>unchecked<br>1<br>«Abstract»<br>Room<br>Person<br>Visit<br>|- roomNr: int {final}<br>- maxRoomCapacity : int {final, static}<br>|- dailyRate : double<br>|- guests : LinkedList<Guest><br>-v: Visit<br>+ Room(roomNr: int , capacity : int, dailyRate : double )<br>setCapacity( int )<br>+ setDailyRate( double )<br>+ addGuest( Guest)<br>+ emptyRoom( ): Visit<br>+ searchGuest( name : String): Guest<br>+ toString(): String<br>getGuestNames(): String<br>+ getVisit( ) : Visit<br>|- name, address, phoneNr: String<br>+ Person( name : String, nationallD: int)<br>-from, to : java.util.Date<br>guestNames : String<br>totalPrice : double<br>+ Visit( from : Date, room: Room)<br>+ endVisit( )<br>getTotalPrice(): double<br>+ getCurrentRevenue( ): double<br>- getVisitDurationInDays( begin, end : Date ): long<br>0.1<br>Employee<br>Guest<br>|- emplD : int {final}<br>|- enlisted : java.util.Date<br>

Extracted text: Hotel ReportPastincome |- rooms : Hashtable |- visits : LinkedList |- 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 -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
Jun 11, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here