Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Durban-World Hotel needs an application that will help them with the booking. They need a GUI application that will generate a total price for
Durban-World Hotel needs an application that will help them with the booking. They need a GUI application that will generate a total price for a booking based on the type of a room, number of people and number of days they will be staying. Room Type Single Double Grand Deluxe Room Code S D G Price Per Person 250 380 495 For a stay of 14 days or more a discount of 15% will be offered; for a stay of 10 days or more 10% discount will be offered; for a stay of 7 days 7.5% discount will be offered. 1 Note the following is provided in the folder for you: Various exception classes are provided below, which must be raised or handled where necessary. Booking Class is given below with attributes and methods BookingDA class, will be given as template, you will need to type missing code where red number is labelled. Read code properly in order to know which missing code you need to type. template classes for GUI Screens-will be given as template, you will need to type missing code where red number is labelled. Read code properly in order to know which missing code you need to type. Note: there will be a text area at the bottom of each question where you will need to type your answer. Various Exception Classes public class DataStorageException extends IOException { public DataStorageException() { } public DataStorageException(String msg) { super(msg);} public class DuplicateException extends Exception { public DuplicateException() { } public DuplicateException(String msg) { super(msg); } public class NotFoundException extends Exception { public NotFoundException() { } public NotFoundException(String msg){ super(msg); } Booking Class public class Booking { private String name, title; private char roomsize; private int ndays,npeoplesharing; public Booking(){ name= title=""; roomsize=''; ndays=npeoplesharing=0; } public Booking(String title, String name, char roomsize, int ndays,int npeoplesharing){ } setName(name); setTitle(title); setRoomSize(roomsize); setNDays(ndays); set NPeopleSharing(npeoplesharing); public void setName(String name){ if(name.length() < 3){ throw new IllegalArgumentException("Invalid name"); }else{ this.name name; }} 2 public void setTitle(String title){ if(title.length() < 2) { throw new IllegalArgumentException("Invalid title"); }else{ this.title = title; } } public void setNDays(int ndays){ if(ndays < 0){ throw new IllegalArgumentException("Invalid number of days"); }else{ } this.ndays = ndays; } public void setNPeopleSharing(int npeoplesharing) { if(ndays < 0){ } } throw new IllegalArgumentException("Invalid number of people"); }else{ this.npeoplesharing = npeoplesharing; public void setRoomSize(char roomsize){ } String strSize = String.valueOf(roomsize).toUpperCase(); if(strSize.equals("S") || strSize.equals("D")|| strSize.equals("G")){ this.roomsize roomsize; }else{ } throw new IllegalArgumentException("Invalid room size"); public String getTitle(){return title;} public String getName(){return name;} public char getRoomSize(){return roomsize; } public int getNdays(){ return ndays; } public int getNpeopleSharing(){ return npeoplesharing; } //end provided class members Implement a three-tier design with Problem Domain (PD), Data Access (DA) and GUI classes. Initial classes are provided as specified above. You will need to modify classes as required. DA - BookingDA class: - Methods must raise necessary exceptions Initialise the data storage-read booking records from file and store it to an array list - called arBook and terminate the data storage - must save arraylist to file. The files must be read and saved using object streams in a file called - booking.dat addNewBooking () - it must add a new booking record to arraylist, make sure there are no duplicate records, use client name to check for duplicates. SearchBooking method, must find and return client booking record based on the client name. getAllBookings method, must return all bookings stored in an arraylist. 3 . Create void method count BookingPerRoomType(), it takes no parameters and processes the arBook array list, validates for each room type and count the number of bookings for that room type and display counted number of booking for each room type in the message dialog. PD-Booking class: - invoke (call) all DA methods accordingly getStdPrice() method that receives no parameters, it must validate for the room type code you are booking for and calculate and return the standard price base on the number of days and number of people sharing. Check table for room type price. calc Discount Amt() method that receives no parameters, calculates and return the discount amount the client will save based on the number of days staying. Check allocated discount percentages for days staying in the problem statement. calcTotalPricePayable() method that receives no parameters, calculates and return total price to be paid after deducting the discount amount. toString() method to display the booking details: ie title, name room type code, number of days, number of people, standard price, discount amount, total price payable. Make sure it has proper tabs. All amounts must be formatted to currencies. Note: you can use NumberFormat class to format Amount values to currencies. Create Java class called: AddBooking that inherits from JFrame Your Screen (Frame) must be created as shown in the screen shot below: It must have a fixed size and not resizable. All components must be added to panel. Combobox component must be populated with Mr, Ms, Prof and Dr titles All components must be aligned correctly- no floating components CLIENT BOOKING FORM Title: Mr Name: Room Size: Single Double Grand Deluxe No of People: No of Days: Add Booking Clear Close On Button Add Booking It must get all inputs from the user and call Booking class and call addNewBooking() from PD class to add all Booking data to arraylist. On Button Clear It must restore form to its original state and set focus to title combobox. 5 On Button Close It must close only this screen, not the whole application Create Java class called: View AllBookings that inherits from JFrame Your Screen (Frame) must be created as shown in the screen shot below: It must have textarea component, placed at the center of the border. TextArea must not be editable. This screen must display all bookings data from arraylist, with correct headings. VIEW ALL CLIENT BOOKINGS SCREEN-BY MS MNGOMA (21000000) Client Name Ms Mngoma Mr Mokoena Room D S NDays 7 NPeople 10 4 Prof Mkwanazi G 4 3 StaPrice R 15,960.00 R 10,000.00 R 5,940.00 DiscAmt R 1,197.00 R 1,000.00 R 0.00 Dr Damiela S 10 7 R 17,500.00 Ms Loubser D 12 5 R 22,800.00 R 1,750.00 R 2,280.00 Tot Payable R 14,763.00 R 9,000.00 R 5,940.00 R 15,750,00 R 20,520.00 Create Java main class called: MenuScreen that inherits from JFrame Your Screen (Frame) must be created as shown in the screen shot below: MAIN MENU - BY MS MNGOMA - X File Bookings Search Booking by Client Name Count No of Booking for Each Room Size Exit MAIN MENU - BY MS MNGOMA File Bookings Add Booking View All Bookings On the default constructor of this class: Handle exception accordingly Call initialise method of PD class On Add Booking menu item Open the Add Booking screen, with screen name, your name and your student no as title of the screen It must have a fixed size and not resizable. On View All Bookings menu item Open the View All Bookings screen, with screen name, your name and your student no as title of the screen It must have a fixed size and not resizable. it must call getAllBookings () method to display all bookings from arraylist On Search booking by Client Name menu item It must use input dialog to get the name of the client to be searched. 5 It must call the searchBooking() method accordingly and display return record in a message box. MAIN MENU - BY MS MNGOMA MAIN MENU - BY MS MNGOMA File Bookings Found Client Booking: Ms Mngoma D 7 6 R 15,960.00 R 1,197.00 R 14,763.00 OK File Bookings Error Message! Moyo dont exist. OK On Count No of Booking for Each Room Size menu item It must call count Booking PerRoomType method accordingly. MAIN MENU - BY MS MNGOMA File Bookings Counted Room Types Single Room Count: 2 Deluxe Room Count: 2 Grand Deluxe Room Count: 1 OK On Exit menu item It must Handle exception accordingly It must confirm if user wants to exit - it must Call terminate method of PD class and exit application on Yes. In the main() method It must open the Menu Screen with screen name, your name and your student no as title of the screen The Screen must Exit on close
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Here is an example implementation of the provided problem statement using Java BookingDAjava import javaio import javautilArrayList public class BookingDA private ArrayList arBook private final String ...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started