From cacd6423a0cff9b955e786babe49e247cadffe46 Mon Sep 17 00:00:00 2001 From: pbd2h21avi Date: Tue, 31 Jan 2023 14:27:24 +0100 Subject: [PATCH] anpassungen --- .../java/com/example/vpr_javafx/Data.java | 38 +++++-- .../example/vpr_javafx/HelloController.java | 43 ++++---- .../com/example/vpr_javafx/LoginDatei.java | 84 +++++++-------- .../java/com/example/vpr_javafx/Menu.java | 2 + .../example/vpr_javafx/MenuOverview-view.fxml | 10 +- .../classes/com/example/vpr_javafx/Data.class | Bin 10027 -> 10353 bytes .../example/vpr_javafx/HelloController.class | Bin 6485 -> 5078 bytes .../com/example/vpr_javafx/LoginDatei.class | Bin 1653 -> 0 bytes .../classes/com/example/vpr_javafx/Menu.class | Bin 1828 -> 2037 bytes .../example/vpr_javafx/MenuOverview-view.fxml | 99 +++++++++--------- .../example/vpr_javafx/Registration-view.fxml | 39 +++++-- 11 files changed, 179 insertions(+), 136 deletions(-) delete mode 100644 target/classes/com/example/vpr_javafx/LoginDatei.class diff --git a/src/main/java/com/example/vpr_javafx/Data.java b/src/main/java/com/example/vpr_javafx/Data.java index 88cfd5c..f8339d4 100644 --- a/src/main/java/com/example/vpr_javafx/Data.java +++ b/src/main/java/com/example/vpr_javafx/Data.java @@ -1,8 +1,6 @@ package com.example.vpr_javafx; -import javafx.fxml.FXML; import javafx.scene.control.Alert; -import javafx.scene.control.Label; import javafx.scene.control.PasswordField; import javafx.scene.control.TextField; @@ -27,15 +25,40 @@ import java.util.regex.Pattern; */ public class Data { private String pathRead; - @FXML - private TextField tfPhone; - @FXML - private PasswordField pfPassword; + public Data(String pathRead) { this.pathRead = pathRead; } + /** + * @author Kevin Pfannenstiel + * @return + */ + public HashMap readLoginData() + { + try { + List lines = Files.readAllLines(Paths.get(pathRead)); + + HashMap user = new HashMap<>(); + + for (int i = 0; i < lines.size(); i++) + { + String[] parts = lines.get(i).split(";"); + + String phoneNumber = parts[3]; + String password = parts[5]; + + user.put(phoneNumber, password); + } + + return user; + + } catch (IOException e) { + e.printStackTrace(); + return new HashMap<>(); + } + } /** * readUser() is a method to split user.txt into lines and save them in an arraylist * @@ -271,8 +294,7 @@ public class Data { boolean phoneNumberValid = false; boolean passwordValid = false; - LoginDatei file = new LoginDatei("user.txt"); - HashMap users = file.readFile(); + HashMap users = readLoginData(); String phoneNumber = tfPhone.getText(); String password = pfPassword.getText(); diff --git a/src/main/java/com/example/vpr_javafx/HelloController.java b/src/main/java/com/example/vpr_javafx/HelloController.java index 3b83fce..d8130fe 100644 --- a/src/main/java/com/example/vpr_javafx/HelloController.java +++ b/src/main/java/com/example/vpr_javafx/HelloController.java @@ -113,6 +113,7 @@ public class HelloController { @FXML protected void FillLabels() { + try { List menu = Files.readAllLines(Paths.get("menue.txt")); @@ -128,85 +129,85 @@ public class HelloController { String dayMenu = dish+"\n"+sideDish+"\n"+"("+allergenic+")"; - if(typ.equals("Fleisch")) { - imageUrl=meatUrl; - } - if(typ.equals("Vegetarisch")) { - imageUrl=veggieImageUrl; - } - if(typ.equals("Vegan")) { - imageUrl=veganUrl; - } - - Image image = new Image("C:/Unterricht/VPR_Projekt/target/classes/com/example/vpr_javafx/" + imageUrl); +// if(typ.equals("Fleisch")) { +// imageUrl=meatUrl; +// } +// if(typ.equals("Vegetarisch")) { +// imageUrl=veggieImageUrl; +// } +// if(typ.equals("Vegan")) { +// imageUrl=veganUrl; +// } +// +// Image image = new Image("C:/Unterricht/VPR_Projekt/target/classes/com/example/vpr_javafx/" + imageUrl); switch (i) { case 0: lMonH1.setText(dayMenu); - imgImage1.setImage(image); +// imgImage1.setImage(image); break; case 1: lMonD1.setText(dayMenu); break; case 2: lMonH2.setText(dayMenu); - imgImage2.setImage(image); +// imgImage2.setImage(image); break; case 3: lMonD2.setText(dayMenu); break; case 4: lTueH1.setText(dayMenu); - imgImage3.setImage(image); +// imgImage3.setImage(image); break; case 5: lTueD1.setText(dayMenu); break; case 6: lTueH2.setText(dayMenu); - imgImage4.setImage(image); +// imgImage4.setImage(image); break; case 7: lTueD2.setText(dayMenu); break; case 8: lWednH1.setText(dayMenu); - imgImage5.setImage(image); +// imgImage5.setImage(image); break; case 9: lWednD1.setText(dayMenu); break; case 10: lWednH2.setText(dayMenu); - imgImage6.setImage(image); +// imgImage6.setImage(image); break; case 11: lWednD2.setText(dayMenu); break; case 12: lThurH1.setText(dayMenu); - imgImage7.setImage(image); +// imgImage7.setImage(image); break; case 13: lThurD1.setText(dayMenu); break; case 14: lThurH2.setText(dayMenu); - imgImage8.setImage(image); +// imgImage8.setImage(image); break; case 15: lThurD2.setText(dayMenu); break; case 16: lFriH1.setText(dayMenu); - imgImage9.setImage(image); +// imgImage9.setImage(image); break; case 17: lFriD1.setText(dayMenu); break; case 18: lFriH2.setText(dayMenu); - imgImage10.setImage(image); +// imgImage10.setImage(image); break; case 19: lFriD2.setText(dayMenu); diff --git a/src/main/java/com/example/vpr_javafx/LoginDatei.java b/src/main/java/com/example/vpr_javafx/LoginDatei.java index 50ca177..54da77d 100644 --- a/src/main/java/com/example/vpr_javafx/LoginDatei.java +++ b/src/main/java/com/example/vpr_javafx/LoginDatei.java @@ -1,42 +1,42 @@ -package com.example.vpr_javafx; - -import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Paths; -import java.util.HashMap; -import java.util.List; - -public class LoginDatei -{ - private final String dateiname; - - public LoginDatei(String dateiname) - { - this.dateiname = dateiname; - } - - public HashMap readFile() - { - try { - List lines = Files.readAllLines(Paths.get(dateiname)); - - HashMap user = new HashMap<>(); - - for (int i = 0; i < lines.size(); i++) - { - String[] parts = lines.get(i).split(";"); - - String phoneNumber = parts[3]; - String password = parts[5]; - - user.put(phoneNumber, password); - } - - return user; - - } catch (IOException e) { - e.printStackTrace(); - return new HashMap<>(); - } - } -} +//package com.example.vpr_javafx; +// +//import java.io.IOException; +//import java.nio.file.Files; +//import java.nio.file.Paths; +//import java.util.HashMap; +//import java.util.List; +// +//public class LoginDatei +//{ +// private final String dateiname; +// +// public LoginDatei(String dateiname) +// { +// this.dateiname = dateiname; +// } +// +// public HashMap readFile() +// { +// try { +// List lines = Files.readAllLines(Paths.get(dateiname)); +// +// HashMap user = new HashMap<>(); +// +// for (int i = 0; i < lines.size(); i++) +// { +// String[] parts = lines.get(i).split(";"); +// +// String phoneNumber = parts[3]; +// String password = parts[5]; +// +// user.put(phoneNumber, password); +// } +// +// return user; +// +// } catch (IOException e) { +// e.printStackTrace(); +// return new HashMap<>(); +// } +// } +//} diff --git a/src/main/java/com/example/vpr_javafx/Menu.java b/src/main/java/com/example/vpr_javafx/Menu.java index 47296bd..d4e58d9 100644 --- a/src/main/java/com/example/vpr_javafx/Menu.java +++ b/src/main/java/com/example/vpr_javafx/Menu.java @@ -71,6 +71,7 @@ public class Menu { /** * The method toString() returns fomated dishdata + * * @return a String with dish, sideDish, list of ingredients and the typ of the menu * @author Madeleine Vigier */ @@ -81,3 +82,4 @@ public class Menu { + type + '\n' + ingredients; } +} diff --git a/src/main/resources/com/example/vpr_javafx/MenuOverview-view.fxml b/src/main/resources/com/example/vpr_javafx/MenuOverview-view.fxml index 9b6e622..d2c88f8 100644 --- a/src/main/resources/com/example/vpr_javafx/MenuOverview-view.fxml +++ b/src/main/resources/com/example/vpr_javafx/MenuOverview-view.fxml @@ -13,7 +13,7 @@ -