total pain

This commit is contained in:
sageTheDM 2024-11-19 16:10:44 +01:00
parent 4c99a1e399
commit bcebce2a6a
15 changed files with 402 additions and 107 deletions

View file

@ -1,115 +1,120 @@
public class FillTable {
// #region Constants
private static final String[] START_TIMES = {
"7:45", "8:35", "9:40", "10:30", "11:20", "12:10", "12:50",
"13:35", "14:25", "15:15", "16:15", "17:05"
};
// #region Constants
private static final String[] START_TIMES = {
"7:45", "8:35", "9:40", "10:30", "11:20", "12:10", "12:50",
"13:35", "14:25", "15:15", "16:15", "17:05"
};
private static final String[] END_TIMES = {
"8:30", "9:20", "10:25", "11:15", "12:05", "12:50", "13:30",
"14:20", "15:10", "16:10", "17:00", "17:50"
};
private static final String[] END_TIMES = {
"8:30", "9:20", "10:25", "11:15", "12:05", "12:50", "13:30",
"14:20", "15:10", "16:10", "17:00", "17:50"
};
// #region Helper Methods
private static void fillTable(String[] teacherShortNames, String day, String[] startTime, String[] endTime,
int roomIndex) {
int dayIndex = getDayIndex(day);
for (int i = 0; i < teacherShortNames.length && i < startTime.length && i < endTime.length; i++) {
Teacher teacher = new Teacher(teacherShortNames[i]); // Initialize Teacher with shortform
App.timeTable[roomIndex][dayIndex][i] = new Lesson(roomIndex, teacher.getName(), startTime[i], endTime[i],
day);
}
}
private static int getDayIndex(String day) {
switch (day) {
case "Monday":
return 0;
case "Tuesday":
return 1;
case "Wednesday":
return 2;
case "Thursday":
return 3;
case "Friday":
return 4;
default:
return -1;
}
}
// #region Fill 37
static void fill37TimeTable() {
int roomIndex = 0;
fillTable(new String[] { "Hm", "Hm", "Hi", "Hm", "Hm", "Lunch", "Bd", "Gi", "Gi", "Ts", "Ts", "" },
"Monday", START_TIMES, END_TIMES, roomIndex);
fillTable(new String[] { "Ts", "Ts", "Ts", "Ts", "Le", "Lunch", "Lunch", "Fh", "Fh", "Fh", "Fh", "" },
"Tuesday", START_TIMES, END_TIMES, roomIndex);
fillTable(new String[] { "Lu", "Lu", "Lu", "Lu", "Cg", "Cg", "Lunch", "Se", "Se", "Se", "Se", "" },
"Wednesday", START_TIMES, END_TIMES, roomIndex);
fillTable(new String[] { "Gi", "Gi", "Ba", "Ba", "Ba", "Lunch", "Bd", "Du", "Lz", "Lz" },
"Thursday", START_TIMES, END_TIMES, roomIndex);
fillTable(new String[] { "Kp", "KP", "Or", "Vt", "Vt", "Lunch", "Lunch", "Du", "Du", "Du", "", "" },
"Friday", START_TIMES, END_TIMES, roomIndex);
}
// #region Fill 38
static void fill38TimeTable() {
int roomIndex = 1;
fillTable(new String[] { "Bz", "Bz", "Bz", "Bz", "Bz", "Lunch", "Lunch", "Hn", "Hn", "Bu", "Hn", "Hn" },
"Monday", START_TIMES, END_TIMES, roomIndex);
fillTable(new String[] { "Kg", "Kg", "Eh", "Re", "Re", "Lunch", "Lunch", "Bt", "Kh", "Kh", "", "" },
"Tuesday", START_TIMES, END_TIMES, roomIndex);
fillTable(new String[] { "Cg", "Cg", "Cg", "Cg", "Es", "Lunch", "Lunch", "Cg", "Cg", "", "", "" },
"Wednesday", START_TIMES, END_TIMES, roomIndex);
fillTable(new String[] { "Do", "Do", "Gr", "Gr", "Or", "Lunch", "Lunch", "Bu", "Bu", "Zu", "", "" },
"Thursday", START_TIMES, END_TIMES, roomIndex);
fillTable(new String[] { "", "Hu", "Ge", "Eh", "Eh", "Bu", "Lunch", "Eh", "Eh", "", "", "" },
"Friday", START_TIMES, END_TIMES, roomIndex);
}
// #region Fill 39
static void fill39TimeTable() {
int roomIndex = 2;
fillTable(new String[] { "Bd", "Bd", "Bd", "Bd", "Bd", "Lunch", "Lunch", "Lu", "Lu", "Lu", "Lu", "" },
"Monday", START_TIMES, END_TIMES, roomIndex);
fillTable(new String[] { "Do", "Do", "Zu", "Zu", "Zu", "Lunch", "Lunch", "Se", "Se", "Se", "Se", "" },
"Tuesday", START_TIMES, END_TIMES, roomIndex);
fillTable(new String[] { "Cg", "Cg", "Cg", "Cg", "Bu", "Lunch", "Lunch", "Gi", "Gi", "Gi", "Gi", "" },
"Wednesday", START_TIMES, END_TIMES, roomIndex);
fillTable(new String[] { "Bd", "Bd", "Bd", "Bd", "Or", "Lunch", "Lunch", "Le", "Le", "Le", "", "" },
"Thursday", START_TIMES, END_TIMES, roomIndex);
fillTable(new String[] { "Gi", "Gi", "Gr", "Gr", "Gi", "Lunch", "Lunch", "Hi", "Hi", "Hi", "", "" },
"Friday", START_TIMES, END_TIMES, roomIndex);
}
static boolean isBreak(int intHour, int intMinute) {
// Check if the time is between 7 AM and 5 PM
if (intHour >= 7 && intHour <= 17) {
// Check if the time falls between any lesson start and end times
for (int i = 0; i < START_TIMES.length; i++) {
// Split the start and end times into hours and minutes
String[] startTime = START_TIMES[i].split(":");
String[] endTime = END_TIMES[i].split(":");
int startHour = Integer.parseInt(startTime[0]);
int startMinute = Integer.parseInt(startTime[1]);
int endHour = Integer.parseInt(endTime[0]);
int endMinute = Integer.parseInt(endTime[1]);
// Check if the given time is during the current lesson
if ((intHour > startHour || (intHour == startHour && intMinute >= startMinute)) &&
(intHour < endHour || (intHour == endHour && intMinute < endMinute))) {
return false; // It's not a break, it's during a lesson
// #region Helper Methods
private static void fillTable(String[] teacherShortNames, String day, String[] startTime, String[] endTime,
int roomIndex) {
int dayIndex = getDayIndex(day);
for (int i = 0; i < teacherShortNames.length && i < startTime.length && i < endTime.length; i++) {
Teacher teacher = new Teacher(teacherShortNames[i]); // Initialize Teacher with shortform
App.timeTable[roomIndex][dayIndex][i] = new Lesson(roomIndex, teacher.getName(), startTime[i],
endTime[i],
day);
}
}
return true; // If no lessons match, it must be a break
}
return false; // Time is outside of the school hours (7 AM to 6 PM roughly)
}
private static int getDayIndex(String day) {
switch (day) {
case "Monday":
return 0;
case "Tuesday":
return 1;
case "Wednesday":
return 2;
case "Thursday":
return 3;
case "Friday":
return 4;
default:
return -1;
}
}
static String whatBreakIsIt(int intHour, int intMinute, int intDay) {
return "No Break"; // If no break is found, return "No Break"
}
// #region Fill 37
static void fill37TimeTable() {
int roomIndex = 0;
fillTable(new String[] { "Hm", "Hm", "Hi", "Hm", "Hm", "Lunch", "Bd", "Gi", "Gi", "Ts", "Ts", "" },
"Monday", START_TIMES, END_TIMES, roomIndex);
fillTable(new String[] { "Ts", "Ts", "Ts", "Ts", "Le", "Lunch", "Lunch", "Fh", "Fh", "Fh", "Fh", "" },
"Tuesday", START_TIMES, END_TIMES, roomIndex);
fillTable(new String[] { "Lu", "Lu", "Lu", "Lu", "Cg", "Cg", "Lunch", "Se", "Se", "Se", "Se", "" },
"Wednesday", START_TIMES, END_TIMES, roomIndex);
fillTable(new String[] { "Gi", "Gi", "Ba", "Ba", "Ba", "Lunch", "Bd", "Du", "Lz", "Lz" },
"Thursday", START_TIMES, END_TIMES, roomIndex);
fillTable(new String[] { "Kp", "KP", "Or", "Vt", "Vt", "Lunch", "Lunch", "Du", "Du", "Du", "", "" },
"Friday", START_TIMES, END_TIMES, roomIndex);
}
// #region Fill 38
static void fill38TimeTable() {
int roomIndex = 1;
fillTable(new String[] { "Bz", "Bz", "Bz", "Bz", "Bz", "Lunch", "Lunch", "Hn", "Hn", "Bu", "Hn", "Hn" },
"Monday", START_TIMES, END_TIMES, roomIndex);
fillTable(new String[] { "Kg", "Kg", "Eh", "Re", "Re", "Lunch", "Lunch", "Bt", "Kh", "Kh", "", "" },
"Tuesday", START_TIMES, END_TIMES, roomIndex);
fillTable(new String[] { "Cg", "Cg", "Cg", "Cg", "Es", "Lunch", "Lunch", "Cg", "Cg", "", "", "" },
"Wednesday", START_TIMES, END_TIMES, roomIndex);
fillTable(new String[] { "Do", "Do", "Gr", "Gr", "Or", "Lunch", "Lunch", "Bu", "Bu", "Zu", "", "" },
"Thursday", START_TIMES, END_TIMES, roomIndex);
fillTable(new String[] { "", "Hu", "Ge", "Eh", "Eh", "Bu", "Lunch", "Eh", "Eh", "", "", "" },
"Friday", START_TIMES, END_TIMES, roomIndex);
}
// #region Fill 39
static void fill39TimeTable() {
int roomIndex = 2;
fillTable(new String[] { "Bd", "Bd", "Bd", "Bd", "Bd", "Lunch", "Lunch", "Lu", "Lu", "Lu", "Lu", "" },
"Monday", START_TIMES, END_TIMES, roomIndex);
fillTable(new String[] { "Do", "Do", "Zu", "Zu", "Zu", "Lunch", "Lunch", "Se", "Se", "Se", "Se", "" },
"Tuesday", START_TIMES, END_TIMES, roomIndex);
fillTable(new String[] { "Cg", "Cg", "Cg", "Cg", "Bu", "Lunch", "Lunch", "Gi", "Gi", "Gi", "Gi", "" },
"Wednesday", START_TIMES, END_TIMES, roomIndex);
fillTable(new String[] { "Bd", "Bd", "Bd", "Bd", "Or", "Lunch", "Lunch", "Le", "Le", "Le", "", "" },
"Thursday", START_TIMES, END_TIMES, roomIndex);
fillTable(new String[] { "Gi", "Gi", "Gr", "Gr", "Gi", "Lunch", "Lunch", "Hi", "Hi", "Hi", "", "" },
"Friday", START_TIMES, END_TIMES, roomIndex);
}
static boolean isBreak(int intHour, int intMinute) {
// Check if the time is between 7 AM and 5 PM
if (intHour >= 7 && intHour <= 17) {
// Check if the time falls between any lesson start and end times
for (int i = 0; i < START_TIMES.length; i++) {
// Split the start and end times into hours and minutes
String[] startTime = START_TIMES[i].split(":");
String[] endTime = END_TIMES[i].split(":");
int startHour = Integer.parseInt(startTime[0]);
int startMinute = Integer.parseInt(startTime[1]);
int endHour = Integer.parseInt(endTime[0]);
int endMinute = Integer.parseInt(endTime[1]);
// Check if the given time is during the current lesson
if ((intHour > startHour || (intHour == startHour && intMinute >= startMinute)) &&
(intHour < endHour || (intHour == endHour && intMinute < endMinute))) {
return false; // It's not a break, it's during a lesson
}
}
return true; // If no lessons match, it must be a break
}
return false; // Time is outside of the school hours (7 AM to 6 PM roughly)
}
static String whatBreakIsIt(int intHour, int intMinute, int intDay) {
boolean isABreak = false;
for (int i = 0; i < END_TIMES.length; i++) {
}
return "No Break"; // If no break is found, return "No Break"
}
}

View file

@ -0,0 +1,51 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>_10_steuerrechner</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-controls</artifactId>
<version>13</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-fxml</artifactId>
<version>13</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<release>11</release>
</configuration>
</plugin>
<plugin>
<groupId>org.openjfx</groupId>
<artifactId>javafx-maven-plugin</artifactId>
<version>0.0.6</version>
<executions>
<execution>
<!-- Default configuration for running -->
<!-- Usage: mvn clean javafx:run -->
<id>default-cli</id>
<configuration>
<mainClass>com.example.App</mainClass>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

View file

@ -0,0 +1,38 @@
package com.example;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;
import java.io.IOException;
/**
* JavaFX App
*/
public class App extends Application {
private static Scene scene;
@Override
public void start(Stage stage) throws IOException {
scene = new Scene(loadFXML("primary"), 640, 480);
stage.setScene(scene);
stage.show();
}
static void setRoot(String fxml) throws IOException {
scene.setRoot(loadFXML(fxml));
}
private static Parent loadFXML(String fxml) throws IOException {
FXMLLoader fxmlLoader = new FXMLLoader(App.class.getResource(fxml + ".fxml"));
return fxmlLoader.load();
}
public static void main(String[] args) {
launch();
}
}

View file

@ -0,0 +1,12 @@
package com.example;
import java.io.IOException;
import javafx.fxml.FXML;
public class PrimaryController {
@FXML
private void switchToSecondary() throws IOException {
App.setRoot("secondary");
}
}

View file

@ -0,0 +1,12 @@
package com.example;
import java.io.IOException;
import javafx.fxml.FXML;
public class SecondaryController {
@FXML
private void switchToPrimary() throws IOException {
App.setRoot("primary");
}
}

View file

@ -0,0 +1,7 @@
module com.example {
requires javafx.controls;
requires javafx.fxml;
opens com.example to javafx.fxml;
exports com.example;
}

View file

@ -0,0 +1,69 @@
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.geometry.Insets?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.TextField?>
<?import javafx.scene.layout.ColumnConstraints?>
<?import javafx.scene.layout.GridPane?>
<?import javafx.scene.layout.HBox?>
<?import javafx.scene.layout.RowConstraints?>
<?import javafx.scene.layout.VBox?>
<?import javafx.scene.text.Text?>
<GridPane alignment="CENTER" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" xmlns:fx="http://javafx.com/fxml/1" xmlns="http://javafx.com/javafx/23.0.1" fx:controller="com.example.PrimaryController">
<columnConstraints>
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
</columnConstraints>
<rowConstraints>
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
</rowConstraints>
<children>
<Text strokeType="OUTSIDE" strokeWidth="0.0" text="Netto" wrappingWidth="90.13000106811523">
<GridPane.margin>
<Insets left="20.0" />
</GridPane.margin>
</Text>
<Text strokeType="OUTSIDE" strokeWidth="0.0" text="Umsatzsteuer" GridPane.rowIndex="1">
<GridPane.margin>
<Insets left="20.0" />
</GridPane.margin>
</Text>
<Text strokeType="OUTSIDE" strokeWidth="0.0" text="Brutto" GridPane.rowIndex="2">
<GridPane.margin>
<Insets left="20.0" />
</GridPane.margin>
</Text>
<TextField fx:id="inpNetto" promptText="Wert eingeben" GridPane.columnIndex="1">
<GridPane.margin>
<Insets right="20.0" />
</GridPane.margin>
</TextField>
<HBox alignment="CENTER_LEFT" prefHeight="100.0" prefWidth="200.0" GridPane.columnIndex="1" GridPane.rowIndex="1">
<children>
<TextField fx:id="inpTax" promptText="Wert eingeben">
<HBox.margin>
<Insets right="20.0" />
</HBox.margin>
</TextField>
<Text strokeType="OUTSIDE" strokeWidth="0.0" text="\%" />
</children>
</HBox>
<VBox alignment="CENTER_LEFT" prefHeight="200.0" prefWidth="100.0" GridPane.columnIndex="1" GridPane.rowIndex="2">
<children>
<TextField fx:id="outBrutto">
<VBox.margin>
<Insets right="20.0" top="20.0" />
</VBox.margin>
</TextField>
<Button mnemonicParsing="false" text="Berechnen">
<VBox.margin>
<Insets top="20.0" />
</VBox.margin>
</Button>
</children>
</VBox>
</children>
</GridPane>

View file

@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.layout.VBox?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.control.Button?>
<?import javafx.geometry.Insets?>
<VBox alignment="CENTER" spacing="20.0" xmlns="http://javafx.com/javafx/8.0.171" xmlns:fx="http://javafx.com/fxml/1" fx:controller="com.example.SecondaryController">
<children>
<Label text="Secondary View" />
<Button fx:id="secondaryButton" text="Switch to Primary View" onAction="#switchToPrimary" />
</children>
<padding>
<Insets bottom="20.0" left="20.0" right="20.0" top="20.0" />
</padding>
</VBox>

View file

@ -0,0 +1,69 @@
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.geometry.Insets?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.TextField?>
<?import javafx.scene.layout.ColumnConstraints?>
<?import javafx.scene.layout.GridPane?>
<?import javafx.scene.layout.HBox?>
<?import javafx.scene.layout.RowConstraints?>
<?import javafx.scene.layout.VBox?>
<?import javafx.scene.text.Text?>
<GridPane alignment="CENTER" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" xmlns:fx="http://javafx.com/fxml/1" xmlns="http://javafx.com/javafx/23.0.1" fx:controller="com.example.PrimaryController">
<columnConstraints>
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
</columnConstraints>
<rowConstraints>
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
</rowConstraints>
<children>
<Text strokeType="OUTSIDE" strokeWidth="0.0" text="Netto" wrappingWidth="90.13000106811523">
<GridPane.margin>
<Insets left="20.0" />
</GridPane.margin>
</Text>
<Text strokeType="OUTSIDE" strokeWidth="0.0" text="Umsatzsteuer" GridPane.rowIndex="1">
<GridPane.margin>
<Insets left="20.0" />
</GridPane.margin>
</Text>
<Text strokeType="OUTSIDE" strokeWidth="0.0" text="Brutto" GridPane.rowIndex="2">
<GridPane.margin>
<Insets left="20.0" />
</GridPane.margin>
</Text>
<TextField fx:id="inpNetto" promptText="Wert eingeben" GridPane.columnIndex="1">
<GridPane.margin>
<Insets right="20.0" />
</GridPane.margin>
</TextField>
<HBox alignment="CENTER_LEFT" prefHeight="100.0" prefWidth="200.0" GridPane.columnIndex="1" GridPane.rowIndex="1">
<children>
<TextField fx:id="inpTax" promptText="Wert eingeben">
<HBox.margin>
<Insets right="20.0" />
</HBox.margin>
</TextField>
<Text strokeType="OUTSIDE" strokeWidth="0.0" text="\%" />
</children>
</HBox>
<VBox alignment="CENTER_LEFT" prefHeight="200.0" prefWidth="100.0" GridPane.columnIndex="1" GridPane.rowIndex="2">
<children>
<TextField fx:id="outBrutto">
<VBox.margin>
<Insets right="20.0" top="20.0" />
</VBox.margin>
</TextField>
<Button mnemonicParsing="false" text="Berechnen">
<VBox.margin>
<Insets top="20.0" />
</VBox.margin>
</Button>
</children>
</VBox>
</children>
</GridPane>

View file

@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.layout.VBox?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.control.Button?>
<?import javafx.geometry.Insets?>
<VBox alignment="CENTER" spacing="20.0" xmlns="http://javafx.com/javafx/8.0.171" xmlns:fx="http://javafx.com/fxml/1" fx:controller="com.example.SecondaryController">
<children>
<Label text="Secondary View" />
<Button fx:id="secondaryButton" text="Switch to Primary View" onAction="#switchToPrimary" />
</children>
<padding>
<Insets bottom="20.0" left="20.0" right="20.0" top="20.0" />
</padding>
</VBox>