Answered step by step
Verified Expert Solution
Question
1 Approved Answer
You must use JavaFX instead of Javax. You Must start the program ONLY by importing following lines: import javafx.application.Application; import javafx.stage.Stage; import javafx.scene.Scene; import javafx.scene.control.*;
You must use JavaFX instead of Javax.
You Must start the program ONLY by importing following lines:
import javafx.application.Application; import javafx.stage.Stage; import javafx.scene.Scene; import javafx.scene.control.*; import javafx.scene.layout.*; import javafx.scene.text.*; import javafx.geometry.*; import javafx.event.ActionEvent;
Inn Room Booking The Golden Dragon Inn has hired you to create an application that allows guests to book rooms. Guests can book either a Luxury or Modest room. To book a room the guest making the booking must provide their name, the number of guests (total) staying in the room, the number of beds (total) required, and the number of nights. These four values are to be entered using a JavaFX GUI interface with the following approximate appearance: Inn Room Cost Calculator O Name: Number of Guests: Number of Beds: Number of Nights: Luxury Modest Reset Welcome to The Golden Dragon Inn! Take note of your check-out time. Enter your information. Once those four text fields are filled in, the user will then click on the appropriate button (Luxury or Modest) to indicate which type of room they want to book. Here is what the interface might look like after clicking the Luxury button: Inn Room Cost Calculator - Name: Nayr the Weird Number of Guests: 5 Number of Beds: 4 Number of Nights: 10 Luxury Modest Reset Your room perk is: Keg of wine Please check-out by: 1pm Total Cost: 600.0gp . After the Luxury" button is pressed (as shown above), the application responds by displaying: A perk to be provided to the guests upon arrival. The software randomly chooses between Keg of wine" or "Wheel of cheese" for the perk; The check-out time, which is always 1 pm for Luxury rooms; and The total cost that is expected for the stay. (More on that in a moment.) Pressing the Reset button returns the application to its original appearance. On the next page is an example of the application after filling in the text fields and then clicking the "Modest" button: Inn Room Cost Calculator Name: Gundo Goodbarrel Number of Guests: 10 Number of Beds: 5 Number of Nights: 7 Luxury Modest Reset Breakfast included in room cost. Please check-out by: 9am Total Cost: 126.0gp After the Modest" button is pressed (as shown above), the application responds by displaying: . The message "Breakfast included in room cost"; . . The check-out time, which for Modest rooms is either 9am or 10am; this is determined randomly at the time the booking is made; and The total cost that is expected for the stay. (More on that in a moment.) As explained in Module 9, your application's source code will include an eventHandler() method that is automatically called whenever any button is pressed. This method has the following first line: public void eventHandler (ActionEvent event) The event variable defined in that line is your key to determining which button the user has pressed. Consider this line of code: if (event.getSource () == resetButton) Place code inside this 'if statement for handling the reset functionality, and handle the Luxury and Modest buttons in the same way. . . . . The cost of a stay is calculated as follows: The Cost of a Luxury Stay: Luxury stays have a base rate of 30 gp (gold pieces) per night for each room, which includes complimentary breakfasts for all guests. The first bed is also included in this price. Each additional bed has a cost of 10 gp per night. The number of guests does not factor into cost calculations for luxury stays. So for the Luxury example shown above: 10 nights at 30 gp = a base cost of 300 gp plus (4-1)=3 beds (3x10=30 gpight) for 10 nights is 300 gp more for a total of 300 + 300 = 600 gp The Cost of a Modest Stay: Modest stays have a base rate of 10 gp (gold pieces) per night for each room. The first two beds are included in this price. Each additional bed has a cost of 1 gp per night. Each guest is charged 0.5 gp per night for breakfast. So for the Modest example shown above: 7 nights at 10 gp = a base cost of 70 gp plus (5-2)=3 beds (3x1=3 gpight) for 7 nights is 21 gp more plus 10 guests @ 0.5 each = 5 gpight for 7 nights is 35 gp more for a total of 70 + 21 + 35 = 126 gp Using CalculatorFX.java as a starting point for organizing your code, your task to create this Inn Booking JavaFX application. The appearance of your application need not match exactly the pictures shown, but yours must include all the GUI components shown. Either a GridPane or a FlowPane should work to arrange the components. Choose a reasonable starting width and height for the Scene so that everything is visible (i.e. nothing is cut off) when the GUI is first displayed
Step by Step Solution
There are 3 Steps involved in it
Step: 1
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