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

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,106 @@
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;
import java.text.DecimalFormat;
public class GPACalculator extends Application {
FlowPane flowPane = new FlowPane();
Text textPointsForCourse = new Text("Welcome to my GPA Calculator!");
Text textCumulativeGPA = new Text("Enter your 1ˢᵗ grade and credit hrs.");
TextField textFieldCLG = new TextField("");
TextField textFieldCCH = new TextField("");
Text textCLG = new Text("Course letter grade:");
Text textCCH = new Text("Course Credit hours:");
Button buttonAddGPA = new Button("Add to GPA");
Button buttonClearGPA = new Button("Clear GPA");
double GPA;
double totalCreditHours;
double totalGradePoints;
public static void main(String[] args) {
launch(args);
}
@Override
public void start(Stage primaryStage) {
primaryStage.setTitle("GPA Calculator");
flowPane.setPadding(new Insets(10, 10, 10, 10));
flowPane.setHgap(10);
flowPane.setVgap(10);
flowPane.setAlignment(Pos.CENTER);
buttonAddGPA.setOnAction(this::AddGPA);
buttonClearGPA.setOnAction(this::ClearGPA);
textFieldCCH.setPrefWidth(50);
textFieldCCH.setOnAction(this::AddGPA);
textFieldCLG.setPrefWidth(50);
textFieldCLG.setOnAction(actionEvent -> textFieldCCH.requestFocus());
flowPane.getChildren().addAll(
textCLG, textFieldCLG,
textCCH, textFieldCCH,
buttonAddGPA, buttonClearGPA,
textPointsForCourse,
textCumulativeGPA);
primaryStage.setScene(new Scene(flowPane, 210, 190));
primaryStage.setResizable(false);
primaryStage.show();
}
private void ClearGPA(ActionEvent actionEvent) {
textCumulativeGPA.setText("Enter your 1ˢᵗ grade and credit hrs.");
textPointsForCourse.setText("Totals have been reset");
textFieldCCH.setText("");
textFieldCLG.setText("");
totalCreditHours = 0;
totalGradePoints= 0;
GPA = 0;
}
private void AddGPA(ActionEvent actionEvent) {
double creditHours = Double.parseDouble(textFieldCCH.getText());
double gradePoints = 0;
String letterGrade = textFieldCLG.getText();
switch (letterGrade.toUpperCase()) {
case "A+":
gradePoints = 4.3*creditHours; break;
case "A":
gradePoints = 4.0*creditHours; break;
case "A-":
gradePoints = 3.7*creditHours; break;
case "B+":
gradePoints = 3.3*creditHours; break;
case "B":
gradePoints = 3.0*creditHours; break;
case "B-":
gradePoints = 2.7*creditHours; break;
case "C+":
gradePoints = 2.3*creditHours; break;
case "C":
gradePoints = 2.0*creditHours; break;
case "D":
gradePoints = 1.0*creditHours; break;
case "F":
case "WF":
gradePoints = 0.0; break;
default:
textPointsForCourse.setText("Invalid Grade - GPA not changed");
break;
}
DecimalFormat df = new DecimalFormat("#.0");
textPointsForCourse.setText("Points for this course: " + df.format(gradePoints));
totalCreditHours = totalCreditHours + Double.parseDouble(textFieldCCH.getText());
totalGradePoints = totalGradePoints + gradePoints;
GPA = totalGradePoints/totalCreditHours;
textCumulativeGPA.setText("Your cumulative GPA is: " + df.format(GPA));
}
}

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.5 KiB