Initial Commit

This commit is contained in:
2022-10-07 00:22:46 -03:00
commit bdcf6d3e1c
465 changed files with 15466 additions and 0 deletions

8
Source Code/Assignment9Q2/.idea/.gitignore generated vendored Normal file
View 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/

View 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>

View File

@ -0,0 +1,5 @@
<component name="ProjectCodeStyleConfiguration">
<state>
<option name="PREFERRED_PROJECT_CODE_STYLE" value="Default" />
</state>
</component>

View 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>

View 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>

View 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>

View 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>

View 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;
}
}

View 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.");
}
}

View 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());
}
}

View 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));
}
}