199 lines
5.4 KiB
Java
199 lines
5.4 KiB
Java
package com.example.vpr_javafx;
|
|
|
|
import javafx.event.ActionEvent;
|
|
import javafx.fxml.FXML;
|
|
import javafx.fxml.FXMLLoader;
|
|
import javafx.scene.Node;
|
|
import javafx.scene.Parent;
|
|
import javafx.scene.Scene;
|
|
import javafx.scene.control.*;
|
|
import javafx.stage.Stage;
|
|
|
|
import java.io.IOException;
|
|
import java.nio.file.Files;
|
|
import java.nio.file.Paths;
|
|
import java.util.HashMap;
|
|
import java.util.List;
|
|
|
|
public class HelloController {
|
|
@FXML
|
|
private Label lMonH1;
|
|
@FXML
|
|
private Label lMonH2;
|
|
@FXML
|
|
private Label lMonD1;
|
|
@FXML
|
|
private Label lMonD2;
|
|
@FXML
|
|
private Label lTueH1;
|
|
@FXML
|
|
private Label lTueH2;
|
|
@FXML
|
|
private Label lTueD1;
|
|
@FXML
|
|
private Label lTueD2;
|
|
@FXML
|
|
private Label lWednH1;
|
|
@FXML
|
|
private Label lWednH2;
|
|
@FXML
|
|
private Label lWednD1;
|
|
@FXML
|
|
private Label lWednD2;
|
|
@FXML
|
|
private Label lThurH1;
|
|
@FXML
|
|
private Label lThurH2;
|
|
@FXML
|
|
private Label lThurD1;
|
|
@FXML
|
|
private Label lThurD2;
|
|
@FXML
|
|
private Label lFriH1;
|
|
@FXML
|
|
private Label lFriH2;
|
|
@FXML
|
|
private Label lFriD1;
|
|
@FXML
|
|
private Label lFriD2;
|
|
|
|
@FXML
|
|
private TextField tfPhone;
|
|
@FXML
|
|
private PasswordField pfPassword;
|
|
|
|
private Stage stage;
|
|
private Scene scene;
|
|
@FXML
|
|
private Label allergene;
|
|
|
|
@FXML
|
|
protected void OnSignInButton(ActionEvent event) throws IOException
|
|
{
|
|
LoginDatei file = new LoginDatei("user.txt");
|
|
HashMap<String, String> users = file.readFile();
|
|
|
|
String phoneNumber = tfPhone.getText();
|
|
String password = pfPassword.getText();
|
|
|
|
Data data = new Data("user.txt");
|
|
boolean inputValid = data.validateData(password, phoneNumber);
|
|
|
|
if (users.containsKey(phoneNumber) && inputValid)
|
|
{
|
|
if (users.get(phoneNumber).equals(password))
|
|
{
|
|
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@FXML
|
|
protected void FillLabels() {
|
|
try {
|
|
List<String> menu = Files.readAllLines(Paths.get("menue.txt"));
|
|
|
|
for (int i = 0; i < menu.size(); i++)
|
|
{
|
|
String[] parts = menu.get(i).split(";");
|
|
|
|
String dish = parts[1];
|
|
String sideDish = parts[2];
|
|
|
|
String dayMenu = dish+"\n"+sideDish;
|
|
|
|
switch (i) {
|
|
case 0:
|
|
lMonH1.setText(dayMenu);
|
|
break;
|
|
case 1:
|
|
lMonD1.setText(dayMenu);
|
|
break;
|
|
case 2:
|
|
lMonH2.setText(dayMenu);
|
|
break;
|
|
case 3:
|
|
lMonD2.setText(dayMenu);
|
|
break;
|
|
case 4:
|
|
lTueH1.setText(dayMenu);
|
|
break;
|
|
case 5:
|
|
lTueD1.setText(dayMenu);
|
|
break;
|
|
case 6:
|
|
lTueH2.setText(dayMenu);
|
|
break;
|
|
case 7:
|
|
lTueD2.setText(dayMenu);
|
|
break;
|
|
case 8:
|
|
lWednH1.setText(dayMenu);
|
|
break;
|
|
case 9:
|
|
lWednD1.setText(dayMenu);
|
|
break;
|
|
case 10:
|
|
lWednH2.setText(dayMenu);
|
|
break;
|
|
case 11:
|
|
lWednD2.setText(dayMenu);
|
|
break;
|
|
case 12:
|
|
lThurH1.setText(dayMenu);
|
|
break;
|
|
case 13:
|
|
lThurD1.setText(dayMenu);
|
|
break;
|
|
case 14:
|
|
lThurH2.setText(dayMenu);
|
|
break;
|
|
case 15:
|
|
lThurD2.setText(dayMenu);
|
|
break;
|
|
case 16:
|
|
lFriH1.setText(dayMenu);
|
|
break;
|
|
case 17:
|
|
lFriD1.setText(dayMenu);
|
|
break;
|
|
case 18:
|
|
lFriH2.setText(dayMenu);
|
|
break;
|
|
case 19:
|
|
lFriD2.setText(dayMenu);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
catch (IOException e) {
|
|
e.printStackTrace();
|
|
}
|
|
|
|
}
|
|
|
|
/**
|
|
* writeAllergene() is a method to format and set allergene
|
|
* @author Madeleine Vigier
|
|
*/
|
|
@FXML
|
|
protected void writeAllergene() {
|
|
allergene.setText("a: Eier; b: Soja,\n"
|
|
+ "c: Milch; d: Erdnüsse;\n"
|
|
+ "e: Weichtiere; f: Krebstiere;\n"
|
|
+ "g: Getreide; h: Senf; i: Sesam;\n"
|
|
+ "j: Schwefeldioxid und Sulfit;\n"
|
|
+ "k: Nüsse; l: Sellerie;\n"
|
|
+ "m: Fische; n: Lupinen\n\n"
|
|
+ "1: Nitrit-Pökelsalz\n"
|
|
+ "2:Phosphat\n"
|
|
+ "3: Nitrat\n"
|
|
+ "4: Antioxidationsmittel\n"
|
|
+ "5: Farbstoff\n"
|
|
+ "6: Geschmacksverstärker;\n"
|
|
+ "7: Süßungsmittel;\n"
|
|
+ "8: Konservierungsstoff");
|
|
}
|
|
|
|
} |