From 27b2186c8721834fb4ceb2132cbc958fd6ecfe80 Mon Sep 17 00:00:00 2001 From: pbd2h21avi Date: Sat, 17 Dec 2022 17:29:42 +0100 Subject: [PATCH] Tagname aus Datum erzeugt --- .../VPR_SCRIPT/GeneralMethods.class | Bin 4048 -> 1420 bytes src/GeneralMethods.java | 247 +++++++++++------- 2 files changed, 148 insertions(+), 99 deletions(-) diff --git a/out/production/VPR_SCRIPT/GeneralMethods.class b/out/production/VPR_SCRIPT/GeneralMethods.class index 2ad1d63cfea99ef7fce8904a45fafa2efcff6926..f35d2d247871fbacfa89873d01fc67d8ac1e6ee1 100644 GIT binary patch literal 1420 zcma)6+fvg|6kP|}Can>%;Dvg>m!hqA(R!zXXj2{Q;P`lG4>Vd54W}}Ef`8#BR3DJ> z!4L4G9M?%oX9uipUf!_8m>qZSell1K@Re~@2fsV)80(yQeU zs-Xo^_dVa!4+Tc^(@QpNflRYmblu`6uM9HSXTfo>A7cV%qj2r5snSXiu1Q_0NUh#d zpN~|nLV*)X`U120>Tbrm4n2RhJRN`fFG@L$aU8UebufX+9o`-7wM*5YA=^s8 zT6p%xeNuZbkc|NctYyRdu!AEw%5pY5-P(!TAvEZ`CqfzIaLmGS2Pbe+U}Cou5wz)p zK=P9e*D33RWzV%_SXZAr%5SLhUTPoY(+6isIh=NI24@AFRi!I(^VP~br9KKA$q$C~ z4GcMt3l=UqxP<%==f01CO{^u^?vOS&U@?ONW-MHGa0Nwyu?6L;P_|vATS0T3-HcP$ zydVon(Jx35j0vhZWFH(_{Mon3gp=b2o$AoTqq&Hq2CR`>!k8uQ1QyT&o z2gftKm4kJdKY?S79r|lF?2(TDgJ|*3?`62G%Yd?X1Kzt+<`9~4bJ*G+7K=&K8aG2g zEDG$eYuWhd%1^yEWa>dDY^Zt9G-_hF7e%wPT%ZEa1apmo8;ca5cd3;q1!c1E6XH8x zMsSZ$V+JNs=F^ECc&OmSgNqCyOY$9O_5g=2V%Ii{NAF;u}bB22-?JQi3( z+AM01##dSl-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}f#7fuf-E9(Jsfk0u2>6~4cOf}SAeY19OhY*;9HYy?jt!hMKqU4gsU z`92P0yWhuCqh0MsR&ewNUb=(!>D$PR^?ZP10;ymk=o557Nsr?Y-62KIz6k|G@Z1zi|BJ)w?pllpElc2L_n=!U24MTnM^_3sJXniT0=3xWxKX z4=u00(|fC0M&cF%yp%V@0_*5H{^_ot2-{t~y7~wQczM0FdJHZ6Ox?_?+Ro3^Bdo0B z{GQC>5Kgng&hne`0{*p;T!%d#Jixc<=Bls96@h5)J z{h1#A!W;M-#_)H}t$$z~pU~r{m|#ymC$?cq?8RBp%deY*I42I_yf}*I#V}qF&*FkO zjTgl7fl`c!_TVa|IK6DgA|;g`Icg*H>5w}KjHZ!3xjT^3b{zTnMTOS z6Zod|M_&58oXJiS-;(~w(JnW8l}v5Lx2bC;UmY%v7BbR;SE*|ycZ!Rsjf{_b8Ib=n zUULz(2p!+SchN*X*XDz`#v7htbwq`O@8bvleCVQu$Hg4E@K8|ly-A(t?R5?UIXwmu zU&UU8+==mqf?>`L4iexV^7kMhvE9i!oMJfYUaxinZS?MrtKo#2k3rNx8Kp> zWvJbL^9AJW_6oekwQ_hB3#4Vq9gaJ^ll}~+4|fm}0i_?4kfxeJC^d6Flpvba$lA0E g;7y)r!cXv1t`TPUGyeYte#NI4rFZdb{1%D-0N78;xBvhE diff --git a/src/GeneralMethods.java b/src/GeneralMethods.java index 603906a..a357ddc 100644 --- a/src/GeneralMethods.java +++ b/src/GeneralMethods.java @@ -4,120 +4,169 @@ import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; +import java.time.DayOfWeek; +import java.time.LocalDate; +import java.time.format.DateTimeFormatter; import java.util.ArrayList; import java.util.List; +import java.util.Locale; -/**GeneralMethods is a class for commen public methods. - * - * @auhtor Felix Wöstemeyer +/** + * GeneralMethods is a class for commen public methods. * * @version 1.0 + * @auhtor Felix Wöstemeyer */ public class GeneralMethods { - /**The method writeData saves the given data to a certain file. - * - * @param pathWrite the given filepath to write - * @param data the data to be saved + + /** + * The method getDayNumberNew() gets the Number of day in week + * @param dateString date as String e.g. 12.12.2022 + * @return the Number of day in week + * @version 1.0 + * @author Madeleine Vigier */ - public static void writeData(String pathWrite, ArrayList data){ - try{ - BufferedWriter writer = new BufferedWriter(new FileWriter(pathWrite)); - for (String d : data) { - writer.write(d); - writer.newLine(); - } - writer.close(); - } catch (IOException e) { - e.printStackTrace(); - } + public static String getDayNumberNew(String dateString) { + + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd.MM.yyyy"); + formatter = formatter.withLocale(Locale.GERMANY); // Locale specifies human language for translating, and cultural norms for lowercase/uppercase and abbreviations and such. Example: Locale.US or Locale.CANADA_FRENCH + LocalDate date = LocalDate.parse(dateString, formatter); + + DayOfWeek day = date.getDayOfWeek(); + return getDayName(day.getValue()); } /** - * Author: Sabine Gubitz - *ddd - * The method read Data interprets a file and returns an useable list for other methods. - * Files to be read have to use : as a divider between attributes - * - * @param pathRead determines the filename of the file that will be read - * @return menueList, userList, orderList depending on Data read + * The method getDayName() gets the weekday + * @param dayNumber dayNumber e.g. 1 for Monday + * @return weekday + * @version 1.0 + * @author Madeleine Vigier */ - public static ArrayList readData(String pathRead) { - Path path = Paths.get(pathRead); - - try { - List rows = Files.readAllLines(path); - - if (pathRead.equals("menue.txt")) { - ArrayList menueList = new ArrayList<>(); - - for (String row : rows) { - String[] parts = row.split(":"); - - String day = parts[0]; - String date = parts[1]; - String meat = parts[2]; - String vegi = parts[3]; - String vegan = parts[4]; - String desert1 = parts[5]; - String desert2 = parts[6]; - menueList.add(day + "," + date + "," + meat + "," + vegi + "," + vegan + "," + desert1 + "," + desert2); - } - return menueList; - - } else if (pathRead.equals("users.txt")){ - ArrayList userList = new ArrayList<>(); - - for (String row : rows) { - String[] parts = row.split(":"); - - String nameParent1 = parts[0]; - String nameParent2 = parts[1]; - String billAddress = parts[2]; - String phonenumber = parts[3]; - String nameChildren = parts[4]; - String password = parts[5]; - } - return userList; - - } else if (pathRead.equals("orders.txt")) { - ArrayList orderList = new ArrayList<>(); - - for (String row : rows) { - String[] parts = row.split(":"); - - String date = parts[0]; - String meat = parts[1]; - String meatCount = parts[2]; - String vegi = parts[3]; - String vegiCount = parts[4]; - String vegan = parts[5]; - String veganCount = parts[6]; - String desert1 = parts[7]; - String desert1Count = parts[8]; - String desert2 = parts[9]; - String desert2Count = parts[10]; - } - return orderList; - - } - } catch (IOException e) { - e.printStackTrace(); + public static String getDayName(int dayNumber) { + if (dayNumber == 1) { + return "Montag"; } + if (dayNumber == 2) { + return "Dienstag"; + } + if (dayNumber == 3) { + return "Mittwoch"; + } + if (dayNumber == 4) { + return "Donnerstag"; + } + if (dayNumber == 5) { + return "Freitag"; + } + return null; } - - /** - * The method writeData2 writes the data of a List into a txt file. - * @param pathWrite determines the filename of the file that will be written - * @param listToWrite determines which ArrayList is to be used for writing the file - */ - public void writeData2 (String pathWrite, ArrayList listToWrite){ - if (pathWrite.equals("users.txt")) { - - } else if (pathWrite.equals("orders.txt")) { - - } - } +// /**The method writeData saves the given data to a certain file. +// * +// * @param pathWrite the given filepath to write +// * @param data the data to be saved +// */ +// public static void writeData(String pathWrite, ArrayList data){ +// try{ +// BufferedWriter writer = new BufferedWriter(new FileWriter(pathWrite)); +// for (String d : data) { +// writer.write(d); +// writer.newLine(); +// } +// writer.close(); +// } catch (IOException e) { +// e.printStackTrace(); +// } +// } +// +// /** +// * Author: Sabine Gubitz +// *ddd +// * The method read Data interprets a file and returns an useable list for other methods. +// * Files to be read have to use : as a divider between attributes +// * +// * @param pathRead determines the filename of the file that will be read +// * @return menueList, userList, orderList depending on Data read +// */ +// public static ArrayList readData(String pathRead) { +// Path path = Paths.get(pathRead); +// +// try { +// List rows = Files.readAllLines(path); +// +// if (pathRead.equals("menue.txt")) { +// ArrayList menueList = new ArrayList<>(); +// +// for (String row : rows) { +// String[] parts = row.split(":"); +// +// String day = parts[0]; +// String date = parts[1]; +// String meat = parts[2]; +// String vegi = parts[3]; +// String vegan = parts[4]; +// String desert1 = parts[5]; +// String desert2 = parts[6]; +// menueList.add(day + "," + date + "," + meat + "," + vegi + "," + vegan + "," + desert1 + "," + desert2); +// } +// return menueList; +// +// } else if (pathRead.equals("users.txt")){ +// ArrayList userList = new ArrayList<>(); +// +// for (String row : rows) { +// String[] parts = row.split(":"); +// +// String nameParent1 = parts[0]; +// String nameParent2 = parts[1]; +// String billAddress = parts[2]; +// String phonenumber = parts[3]; +// String nameChildren = parts[4]; +// String password = parts[5]; +// } +// return userList; +// +// } else if (pathRead.equals("orders.txt")) { +// ArrayList orderList = new ArrayList<>(); +// +// for (String row : rows) { +// String[] parts = row.split(":"); +// +// String date = parts[0]; +// String meat = parts[1]; +// String meatCount = parts[2]; +// String vegi = parts[3]; +// String vegiCount = parts[4]; +// String vegan = parts[5]; +// String veganCount = parts[6]; +// String desert1 = parts[7]; +// String desert1Count = parts[8]; +// String desert2 = parts[9]; +// String desert2Count = parts[10]; +// } +// return orderList; +// +// } +// } catch (IOException e) { +// e.printStackTrace(); +// } +// return null; +// } +// +// +// /** +// * The method writeData2 writes the data of a List into a txt file. +// * @param pathWrite determines the filename of the file that will be written +// * @param listToWrite determines which ArrayList is to be used for writing the file +// */ +// public void writeData2 (String pathWrite, ArrayList listToWrite){ +// if (pathWrite.equals("users.txt")) { +// +// } else if (pathWrite.equals("orders.txt")) { +// +// } +// } }