Description
1. Sweet Hotel is a four-star hotel that offers promotion for vacation at reduced rates. The company is
committed to offer the best services to its customers with the fast check-in process. Sweet Hotel also
providing a sought out some attractive promotions with discount price that will fit customer’s plan and
budget.
To help staff to search for details of customer booking during check-in process, Sweet Hotel appoint
you as a programmer to develop a system. Figure 1 shows the UML class diagram as the information
needed in the development of Hotel promotion and check-in system.
There are some attractive promotions with discount prices to choose from, according to customers’ needs.
Promotion Type Price (RM) Promotion
discount
L – Luxury 4000.00 25%
B – Budget 1500.00 20%
S – SweetEscape 3300.00 15%
Formula: Promotion = Price * Promotion discount * Day
a) Write a complete definition of the class Room.
b) Write a complete definition of the class HotelPromotion. Add the following methods in the class
definition.
i. Processor methods calculatePromotion() to calculate and return the price after promotion
discount that should be paid by the customer.
ii. Processor method isSameBlock(HotelPromotion) that compares two
HotelPromotion objects. It returns true if the objects are located at the same block. It returns
false otherwise.
iii. A printer method that displays all the information of the HotelPromotion object.
c) Write Java application (main program) for the following tasks:
i. Declare an array named promo that can hold 50 objects.
ii. Read and store all data into objects.
iii. Count and display the booking code of customers who already paid for booking.
iv. Find the customer check-in based on booking code entered by the user. If therecord found displays the
customer’s detail and balance of payment that he/she need to pay. If the record does not exist, display
an appropriate message.
2. MoveR is an efficient and professional rental company that offers full range of transportation for hire. The
company is committed to offer the best transportation services to its customers with the least hassle and
procedures. Besides giving the best and consistent rental experiences to the renters, MoveR also provides a
flexible option and reasonable price that will fit renter’s requirement budget and schedule.
To keep track of the renter information, either existing or prospective renters, MoveR hires InsanSoftHouse
Sdn Bhd a well-known developer company to develop a system. This system will ensure the renters receive
the best services from them.
Figure 1 shows the UML class diagram as the information needed in this development process.
Address
-streetName: String
-district: String
-state:String
+Address(String,String,String)
+setAddress(String,String,String): void
+getStreetName():String
+getDistrict:String
+getState():String
+toString():String
Renter
-name: String
-contactNo: String
-address:Address
-travelDistance:double
-lorrytype:char
-driver:boolean
+Renter (String,String,String,String,String,double,char,boolean)
+setRenter(String,String,String,String,String,double,char,boolean): void
+getName():String
+getAddress():Address
+getTravelDistance():double
+getLorryType():char
+getDriver():boolean
+calculateSpecialService():double
+calculateTotalPrice():double
+displayRenter():void
Figure 1: UML class diagram of the class Renter and composition
There are various moving services and lorry options to choose from, according to renter needs. The charges for
lorry type are as follows:
Type of
Lorry
Description Charges
A 1 Ton (10 ft) with 2 movers RM560.00
B 3 Ton (17 ft) with 3 movers RM720.00
C 5 Ton (17 ft) with 5 movers RM1300.00
Total price is calculated based on the lorry type rented plus with the special service charges. Additionally, if the
travel distance is more than 200 km, renter will need to pay extra RM350.
Special service cost is charged if driver is needed for the lorry rental. For every driver, the extra charge is
RM150. Number of drivers is calculated based on the distance of the trip as shown below:
Trip
Distance
Number of
driver
>= 200 km 2
< 200 km 1
Based on the given information, answer all the following questions:
a) Write a complete definition of the class Address.
b) Write a complete definition of the class Renter. Add the following methods in the class
definition.
• normal constructor for all data members.
• accessor methods for each data member.
• processor methods; calculateSpecialService() and
calculateTotalPrice().
• display method.
c) Write the main method to do the following tasks:
• Declare an array to store Renter objects. The size of array is determined by the user.
• Read and store all data into the array of objects.
• Count and display the number of renters who choose 1-ton lorry with no driver option.
• Find and display the details of renter based on contact number entered by the user. If the record
does not exist, display an appropriate message.