Initial Commit
This commit is contained in:
23
Submissions/CS1073 As9/Zip/2/ElitePackageBooking.java
Normal file
23
Submissions/CS1073 As9/Zip/2/ElitePackageBooking.java
Normal file
@ -0,0 +1,23 @@
|
||||
public class ElitePackageBooking extends TouristPackageBooking{
|
||||
|
||||
ElitePackageBooking(long aLaCarteMeals, long spaVisits) {
|
||||
super(aLaCarteMeals, spaVisits);
|
||||
}
|
||||
|
||||
@Override
|
||||
double getTotalCost() {
|
||||
double aLaCarteMealsCost;
|
||||
if (aLaCarteMeals <= 3) {
|
||||
aLaCarteMealsCost = 0.00;
|
||||
}
|
||||
else {
|
||||
aLaCarteMealsCost = (aLaCarteMeals -3) * 35.00;
|
||||
}
|
||||
return ((super.basePrice+775) + (aLaCarteMealsCost) + (spaVisits*75));
|
||||
}
|
||||
|
||||
@Override
|
||||
int getBuildingNumber() {
|
||||
return 1;
|
||||
}
|
||||
}
|
78
Submissions/CS1073 As9/Zip/2/GUIFrontEnd.java
Normal file
78
Submissions/CS1073 As9/Zip/2/GUIFrontEnd.java
Normal file
@ -0,0 +1,78 @@
|
||||
import javafx.application.Application;
|
||||
import javafx.event.ActionEvent;
|
||||
import javafx.geometry.Insets;
|
||||
import javafx.geometry.Pos;
|
||||
import javafx.scene.Scene;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.control.TextField;
|
||||
import javafx.scene.layout.FlowPane;
|
||||
import javafx.scene.text.Text;
|
||||
import javafx.stage.Stage;
|
||||
|
||||
public class GUIFrontEnd extends Application {
|
||||
FlowPane flowPane = new FlowPane();
|
||||
Text textBuildingNumber = new Text("Welcome to Paradise Palms!");
|
||||
Text textTotalCost = new Text("Enter your booking information.");
|
||||
TextField textFieldName = new TextField("");
|
||||
TextField textFieldALCM = new TextField("");
|
||||
TextField textFieldNSV = new TextField("");
|
||||
Text textName = new Text("Guest Name:");
|
||||
Text textALCM = new Text("Number of \u00E0 la Carte Meals:");
|
||||
Text textNSV = new Text("Number of Spa Visits:");
|
||||
Button buttonTourist = new Button("Tourist");
|
||||
Button buttonElite = new Button("Elite");
|
||||
Button buttonReset = new Button("Reset");
|
||||
|
||||
public static void main(String[] args) {
|
||||
launch(args);
|
||||
}
|
||||
@Override
|
||||
public void start(Stage primaryStage) {
|
||||
primaryStage.setTitle("Package Calculator");
|
||||
flowPane.setPadding(new Insets(10, 10, 10, 10));
|
||||
flowPane.setHgap(10);
|
||||
flowPane.setVgap(15);
|
||||
flowPane.setAlignment(Pos.CENTER);
|
||||
|
||||
buttonElite.setOnAction(this::calculateElite);
|
||||
buttonTourist.setOnAction(this::calculateTourist);
|
||||
buttonReset.setOnAction(this::reset);
|
||||
|
||||
textFieldName.setPrefWidth(120);
|
||||
textFieldALCM.setPrefWidth(50);
|
||||
textFieldNSV.setPrefWidth(50);
|
||||
|
||||
flowPane.getChildren().addAll(
|
||||
textName, textFieldName,
|
||||
textALCM, textFieldALCM,
|
||||
textNSV, textFieldNSV,
|
||||
buttonTourist, buttonElite, buttonReset,
|
||||
textBuildingNumber,
|
||||
textTotalCost);
|
||||
|
||||
primaryStage.setScene(new Scene(flowPane, 220, 250));
|
||||
primaryStage.setResizable(false);
|
||||
primaryStage.show();
|
||||
}
|
||||
|
||||
private void calculateElite(ActionEvent actionEvent) {
|
||||
ElitePackageBooking tourist = new ElitePackageBooking(Long.parseLong(textFieldALCM.getText()), Long.parseLong(textFieldNSV.getText()));
|
||||
ResortBooking resort = new ResortBooking(tourist, textFieldName.getText());
|
||||
textBuildingNumber.setText(resort.getBuildingNumber(tourist));
|
||||
textTotalCost.setText(resort.getTotalCost(tourist));
|
||||
|
||||
}
|
||||
private void calculateTourist(ActionEvent actionEvent) {
|
||||
TouristPackageBooking tourist = new TouristPackageBooking(Long.parseLong(textFieldALCM.getText()), Long.parseLong(textFieldNSV.getText()));
|
||||
ResortBooking resort = new ResortBooking(tourist, textFieldName.getText());
|
||||
textBuildingNumber.setText(resort.getBuildingNumber(tourist));
|
||||
textTotalCost.setText(resort.getTotalCost(tourist));
|
||||
}
|
||||
private void reset(ActionEvent actionEvent) {
|
||||
textFieldName.setText("");
|
||||
textFieldALCM.setText("");
|
||||
textFieldNSV.setText("");
|
||||
textBuildingNumber.setText("Welcome to Paradise Palms!");
|
||||
textTotalCost.setText("Enter your booking information.");
|
||||
}
|
||||
}
|
33
Submissions/CS1073 As9/Zip/2/ResortBooking.java
Normal file
33
Submissions/CS1073 As9/Zip/2/ResortBooking.java
Normal file
@ -0,0 +1,33 @@
|
||||
import java.text.DecimalFormat;
|
||||
import java.text.NumberFormat;
|
||||
import java.util.Locale;
|
||||
|
||||
public class ResortBooking {
|
||||
String name;
|
||||
TouristPackageBooking tTourist;
|
||||
ElitePackageBooking eTourist;
|
||||
NumberFormat cf = NumberFormat.getCurrencyInstance(Locale.CANADA);
|
||||
|
||||
ResortBooking(TouristPackageBooking touristIn, String name) {
|
||||
tTourist = touristIn;
|
||||
this.name = name;
|
||||
}
|
||||
ResortBooking(ElitePackageBooking touristIn, String name) {
|
||||
eTourist = touristIn;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
String getBuildingNumber(TouristPackageBooking tourist) {
|
||||
return "Building Number: " + tourist.getBuildingNumber();
|
||||
}
|
||||
String getBuildingNumber(ElitePackageBooking tourist) {
|
||||
return "Building Number: " + tourist.getBuildingNumber();
|
||||
}
|
||||
|
||||
String getTotalCost(TouristPackageBooking tourist) {
|
||||
return "Total price for this package: " + cf.format(tourist.getTotalCost());
|
||||
}
|
||||
String getTotalCost(ElitePackageBooking tourist) {
|
||||
return "Total price for this package: " + cf.format(tourist.getTotalCost());
|
||||
}
|
||||
}
|
23
Submissions/CS1073 As9/Zip/2/TouristPackageBooking.java
Normal file
23
Submissions/CS1073 As9/Zip/2/TouristPackageBooking.java
Normal file
@ -0,0 +1,23 @@
|
||||
public class TouristPackageBooking {
|
||||
final double basePrice = 1475.00;
|
||||
long aLaCarteMeals;
|
||||
long spaVisits;
|
||||
|
||||
TouristPackageBooking(long aLaCarteMeals, long spaVisits) {
|
||||
this.aLaCarteMeals = aLaCarteMeals;
|
||||
this.spaVisits = spaVisits;
|
||||
}
|
||||
double getTotalCost() {
|
||||
double spaVisitCosts = 0;
|
||||
if (spaVisits == 1) {
|
||||
spaVisitCosts = 125.00;
|
||||
}
|
||||
else if (spaVisits > 1) {
|
||||
spaVisitCosts = 125 + ((spaVisits - 1) * 100);
|
||||
}
|
||||
return (basePrice + (aLaCarteMeals*35.00) + spaVisitCosts);
|
||||
}
|
||||
int getBuildingNumber() {
|
||||
return (int)((Math.random() * (5-2) + 2));
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user