Initial Commit
This commit is contained in:
8
Source Code/Assignment9Q2/.idea/.gitignore
generated
vendored
Normal file
8
Source Code/Assignment9Q2/.idea/.gitignore
generated
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
# Default ignored files
|
||||
/shelf/
|
||||
/workspace.xml
|
||||
# Datasource local storage ignored files
|
||||
/../../../../../../:\ProgrammingProjects\JavaProjects\JavaYear1\Assignment9Q2\.idea/dataSources/
|
||||
/dataSources.local.xml
|
||||
# Editor-based HTTP Client requests
|
||||
/httpRequests/
|
25
Source Code/Assignment9Q2/.idea/codeStyles/Project.xml
generated
Normal file
25
Source Code/Assignment9Q2/.idea/codeStyles/Project.xml
generated
Normal file
@ -0,0 +1,25 @@
|
||||
<component name="ProjectCodeStyleConfiguration">
|
||||
<code_scheme name="Project" version="173">
|
||||
<JetCodeStyleSettings>
|
||||
<option name="PACKAGES_TO_USE_STAR_IMPORTS">
|
||||
<value>
|
||||
<package name="java.util" alias="false" withSubpackages="false" />
|
||||
<package name="kotlinx.android.synthetic" alias="false" withSubpackages="true" />
|
||||
<package name="io.ktor" alias="false" withSubpackages="true" />
|
||||
</value>
|
||||
</option>
|
||||
<option name="PACKAGES_IMPORT_LAYOUT">
|
||||
<value>
|
||||
<package name="" alias="false" withSubpackages="true" />
|
||||
<package name="java" alias="false" withSubpackages="true" />
|
||||
<package name="javax" alias="false" withSubpackages="true" />
|
||||
<package name="kotlin" alias="false" withSubpackages="true" />
|
||||
<package name="" alias="true" withSubpackages="true" />
|
||||
</value>
|
||||
</option>
|
||||
</JetCodeStyleSettings>
|
||||
<ScalaCodeStyleSettings>
|
||||
<option name="MULTILINE_STRING_CLOSING_QUOTES_ON_NEW_LINE" value="true" />
|
||||
</ScalaCodeStyleSettings>
|
||||
</code_scheme>
|
||||
</component>
|
5
Source Code/Assignment9Q2/.idea/codeStyles/codeStyleConfig.xml
generated
Normal file
5
Source Code/Assignment9Q2/.idea/codeStyles/codeStyleConfig.xml
generated
Normal file
@ -0,0 +1,5 @@
|
||||
<component name="ProjectCodeStyleConfiguration">
|
||||
<state>
|
||||
<option name="PREFERRED_PROJECT_CODE_STYLE" value="Default" />
|
||||
</state>
|
||||
</component>
|
6
Source Code/Assignment9Q2/.idea/discord.xml
generated
Normal file
6
Source Code/Assignment9Q2/.idea/discord.xml
generated
Normal file
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="DiscordProjectSettings">
|
||||
<option name="show" value="PROJECT" />
|
||||
</component>
|
||||
</project>
|
6
Source Code/Assignment9Q2/.idea/misc.xml
generated
Normal file
6
Source Code/Assignment9Q2/.idea/misc.xml
generated
Normal file
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/out" />
|
||||
</component>
|
||||
</project>
|
8
Source Code/Assignment9Q2/.idea/modules.xml
generated
Normal file
8
Source Code/Assignment9Q2/.idea/modules.xml
generated
Normal file
@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/Assignment9Q2.iml" filepath="$PROJECT_DIR$/Assignment9Q2.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
11
Source Code/Assignment9Q2/Assignment9Q2.iml
Normal file
11
Source Code/Assignment9Q2/Assignment9Q2.iml
Normal file
@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
23
Source Code/Assignment9Q2/src/ElitePackageBooking.java
Normal file
23
Source Code/Assignment9Q2/src/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
Source Code/Assignment9Q2/src/GUIFrontEnd.java
Normal file
78
Source Code/Assignment9Q2/src/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
Source Code/Assignment9Q2/src/ResortBooking.java
Normal file
33
Source Code/Assignment9Q2/src/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
Source Code/Assignment9Q2/src/TouristPackageBooking.java
Normal file
23
Source Code/Assignment9Q2/src/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