From d222db88167fd6c341987bd00d3a93eb13b8121e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felix=20D=C3=BCsterhaus?= Date: Tue, 31 Jan 2023 18:20:28 +0100 Subject: [PATCH] =?UTF-8?q?order.txt=20testdatei=20+=20Data=20changeorder(?= =?UTF-8?q?)=20ge=C3=A4ndert?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- order.txt | 5 ++ .../java/com/example/vpr_javafx/Data.java | 52 ++++++++++-------- src/main/java/module-info.java | 1 + .../classes/com/example/vpr_javafx/Data.class | Bin 10522 -> 11198 bytes target/classes/module-info.class | Bin 262 -> 286 bytes 5 files changed, 34 insertions(+), 24 deletions(-) diff --git a/order.txt b/order.txt index e69de29..087e457 100644 --- a/order.txt +++ b/order.txt @@ -0,0 +1,5 @@ +2002-02-12;1234567;Vegan;DessertV +2002-02-12;12345678;Vegan;DessertV +2002-02-12;123464353;Vegan;DessertV +2002-02-12;724373;Vegan;DessertV +2002-02-12;73473;Vegan;DessertV \ No newline at end of file diff --git a/src/main/java/com/example/vpr_javafx/Data.java b/src/main/java/com/example/vpr_javafx/Data.java index aea4a35..1fd7dd3 100644 --- a/src/main/java/com/example/vpr_javafx/Data.java +++ b/src/main/java/com/example/vpr_javafx/Data.java @@ -16,6 +16,7 @@ import java.util.List; import java.util.Scanner; import java.util.regex.Matcher; import java.util.regex.Pattern; +import javax.swing.*; /** * Data is a class to edit files. @@ -354,43 +355,46 @@ public class Data { public ArrayList changeOrder(String userLogin) { - /* - File orderFile = new File("C:/Unterricht/VPR/orders.txt"); - if (orderFile.delete()) { - System.out.println("Datei gelöscht: " + orderFile.getName()); - } else { - System.out.println("Fehler, " + orderFile.getName() + " nicht gelöscht."); - } - */ - ArrayList changedOrderList = new ArrayList<>(); List rows = getRows(); int changedEntries = 0; - for (String row : rows) { - String[] parts = row.split(";"); + //ImageIcon icon = new ImageIcon("file:target/classes/com/example/vpr_javafx/pics/vegetarisch.png"); + UIManager.put("OptionPane.noButtonText", "Nein"); + UIManager.put("OptionPane.yesButtonText", "Ja"); + int result = JOptionPane.showInternalConfirmDialog(null, "Bestellungen wirklich Löschen?", "Bestätigung", JOptionPane.YES_NO_OPTION); - String date = parts[0]; - String user = parts[1]; - String mealtyp = parts[2]; - String deserttyp = parts[3]; - if(!userLogin.equals(user)) { - changedOrderList.add(new com.example.vpr_javafx.Order(date, user, mealtyp, deserttyp)); - } else { - changedEntries++; + if (result == JOptionPane.YES_OPTION) { + for (String row : rows) { + String[] parts = row.split(";"); + + String date = parts[0]; + String user = parts[1]; + String mealtyp = parts[2]; + String deserttyp = parts[3]; + if(!userLogin.equals(user)) { + changedOrderList.add(new com.example.vpr_javafx.Order(date, user, mealtyp, deserttyp)); + } else { + changedEntries++; + } } - } - - try { + try { FileWriter writer = new FileWriter("orders2.txt"); for(com.example.vpr_javafx.Order str: changedOrderList) { writer.write(str + System.lineSeparator()); } writer.close(); - System.out.println("Daten gelöscht"); - System.out.println(changedEntries + " Einträge entfernt."); + + + + + } catch (IOException e) { e.printStackTrace(); + } + JOptionPane.showMessageDialog(null, changedEntries + " Bestellungen Gelöscht, Sie können eine neue Bestellung aufgeben"); + } else { + JOptionPane.showMessageDialog(null, "Bestellung nicht gelöscht."); } return changedOrderList; } diff --git a/src/main/java/module-info.java b/src/main/java/module-info.java index 9985380..620978c 100644 --- a/src/main/java/module-info.java +++ b/src/main/java/module-info.java @@ -1,6 +1,7 @@ module com.example.vpr_javafx { requires javafx.controls; requires javafx.fxml; + requires java.desktop; opens com.example.vpr_javafx to javafx.fxml; diff --git a/target/classes/com/example/vpr_javafx/Data.class b/target/classes/com/example/vpr_javafx/Data.class index 20f929bf4275ce004e5864809e2c53659c7d18c8..3666df4e8701beeceb00de2c40a24db55facc7ef 100644 GIT binary patch delta 3653 zcmZuzd303u8NK&qnI)4D2w5ful86coUlj$A?#}~F4ReQgb9>F@)@apMQ{(`-_E7WF&O1cA)Ex|zR=8~nS`UK1j&2e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<2*ydz6KiBYKtY!|Tx1?-d+@$0_Jlly?G zSb}Otmm~tB)D{Kf#cn$wh2zEz{o76N7LuC-G`p!V?b`bA4j;37UX_2_={*+);VO49 zPw4w^^ysR21FH&Gs-5gBeHVQ9lpT-VkVtgy^=!3d6{J+l5cvOLdktqfE4A4Evlkj) z-)~JXN?V%=_t!Stjb7$q^nGEcygx4Q1|!_1?+k^yTU~#^d3HI^Zs+-JKBalRF6&bG OfKN{|d4!g3WAnfCrr1{i diff --git a/target/classes/module-info.class b/target/classes/module-info.class index 03f8e2988bc119e958292dcc3dd51699367c3eda..a911f758a8736632ba75527541e68e7bf16b4aaa 100644 GIT binary patch delta 99 zcmZo;n#aU->ff$?3=9mm48jw+ricnN2rx46WF?j*>ZPO>XP4v`h%g9ETxeo$#=r(t j#lXPAz|p|Kz{S7~=JA3_ejv%kz{ns7=0Rvi2Cy6e5q=H% delta 75 zcmbQo)W*bh>ff$?3=9mm41yE6rZ9^z2u$2;Vram?1{7mpU}oTGU|`^4;0E(}!6YLC LKN8Kz02T!R6qE?j