Compare commits
7 Commits
9663777e25
...
master
Author | SHA1 | Date | |
---|---|---|---|
51e370ad33 | |||
f1fabad17d | |||
deeabfd2ad | |||
6ffc7a6868 | |||
7e507fa95c | |||
f35554f858 | |||
95069e7d8d |
2
.idea/misc.xml
generated
2
.idea/misc.xml
generated
@@ -1,6 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" default="true" project-jdk-name="17" project-jdk-type="JavaSDK">
|
<component name="ProjectRootManager" version="2" languageLevel="JDK_16" project-jdk-name="17" project-jdk-type="JavaSDK">
|
||||||
<output url="file://$PROJECT_DIR$/out" />
|
<output url="file://$PROJECT_DIR$/out" />
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
10
.idea/runConfigurations.xml
generated
10
.idea/runConfigurations.xml
generated
@@ -1,10 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project version="4">
|
|
||||||
<component name="RunConfigurationProducerService">
|
|
||||||
<option name="ignoredProducers">
|
|
||||||
<set>
|
|
||||||
<option value="com.android.tools.idea.compose.preview.runconfiguration.ComposePreviewRunConfigurationProducer" />
|
|
||||||
</set>
|
|
||||||
</option>
|
|
||||||
</component>
|
|
||||||
</project>
|
|
12
orders.txt
Normal file
12
orders.txt
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
12.12.2022;1234567;Vegan;Dessert V
|
||||||
|
12.12.2022;7654321;Vegan;Dessert V
|
||||||
|
12.12.2022;123;Vegetarisch;Dessert V
|
||||||
|
12.12.2022;9999999;Fleisch;Dessert
|
||||||
|
12.12.2022;1234567;Vegan;Dessert V
|
||||||
|
12.12.2022;7654321;Vegan;Dessert V
|
||||||
|
12.12.2022;123;Vegetarisch;Dessert V
|
||||||
|
12.12.2022;9999999;Fleisch;Dessert
|
||||||
|
12.12.2022;1234567;Vegan;Dessert V
|
||||||
|
12.12.2022;7654321;Vegan;Dessert V
|
||||||
|
12.12.2022;123;Vegetarisch;Dessert V
|
||||||
|
12.12.2022;1234;Fleisch;Dessert
|
12
orders2.txt
Normal file
12
orders2.txt
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
12.12.2022;1234567;Vegan;Dessert V
|
||||||
|
12.12.2022;7654321;Vegan;Dessert V
|
||||||
|
12.12.2022;123;Vegetarisch;Dessert V
|
||||||
|
12.12.2022;9999999;Fleisch;Dessert
|
||||||
|
12.12.2022;1234567;Vegan;Dessert V
|
||||||
|
12.12.2022;7654321;Vegan;Dessert V
|
||||||
|
12.12.2022;123;Vegetarisch;Dessert V
|
||||||
|
12.12.2022;9999999;Fleisch;Dessert
|
||||||
|
12.12.2022;1234567;Vegan;Dessert V
|
||||||
|
12.12.2022;7654321;Vegan;Dessert V
|
||||||
|
12.12.2022;123;Vegetarisch;Dessert V
|
||||||
|
12.12.2022;1234;Fleisch;Dessert
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -308,5 +308,55 @@ public class Data {
|
|||||||
}
|
}
|
||||||
return inputValid;
|
return inputValid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The method changes the orders.txt file by removing canceled orders
|
||||||
|
*
|
||||||
|
* @return ArrayList\<Order> changedOrderList
|
||||||
|
* @author Felix Düsterhaus
|
||||||
|
*/
|
||||||
|
|
||||||
|
public ArrayList<Order> 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<Order> changedOrderList = new ArrayList<>();
|
||||||
|
List<String> rows = getRows();
|
||||||
|
int changedEntries = 0;
|
||||||
|
|
||||||
|
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 Order(date, user, mealtyp, deserttyp));
|
||||||
|
} else {
|
||||||
|
changedEntries++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
FileWriter writer = new FileWriter("orders2.txt");
|
||||||
|
for(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();
|
||||||
|
}
|
||||||
|
return changedOrderList;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1,3 +1,5 @@
|
|||||||
|
import java.io.IOException;
|
||||||
|
import java.nio.file.Path;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Scanner;
|
import java.util.Scanner;
|
||||||
|
|
||||||
@@ -5,7 +7,7 @@ import java.util.Scanner;
|
|||||||
* The class Execute is the execution file for the whole program.
|
* The class Execute is the execution file for the whole program.
|
||||||
*/
|
*/
|
||||||
public class Execute {
|
public class Execute {
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) throws IOException {
|
||||||
//EXECUTE MENU OVERVIEW
|
//EXECUTE MENU OVERVIEW
|
||||||
Data data = new Data("menue.txt");
|
Data data = new Data("menue.txt");
|
||||||
ArrayList<Menu> menu = data.readMenu();
|
ArrayList<Menu> menu = data.readMenu();
|
||||||
@@ -45,5 +47,29 @@ public class Execute {
|
|||||||
String password = leser.nextLine();
|
String password = leser.nextLine();
|
||||||
|
|
||||||
login.toLogin(userData.readUser(), password, phoneNumber);
|
login.toLogin(userData.readUser(), password, phoneNumber);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test zum Daten löschen
|
||||||
|
* @author Felix Düsterhaus
|
||||||
|
*/
|
||||||
|
Data orderData = new Data("orders2.txt");
|
||||||
|
System.out.print("Möchten Sie Einträge löschen? (Y/N) ");
|
||||||
|
String orderChangeDecision = leser.nextLine();
|
||||||
|
if (orderChangeDecision.equals("Y") || orderChangeDecision.equals("y")) {
|
||||||
|
ArrayList<Order> changedOrderList = orderData.changeOrder(phoneNumber);
|
||||||
|
} else if (orderChangeDecision.equals("N") || orderChangeDecision.equals("n")) {
|
||||||
|
System.out.println("Daten werden nicht geändert.");
|
||||||
|
}
|
||||||
|
while(!(orderChangeDecision.equals("Y") || orderChangeDecision.equals("y") || orderChangeDecision.equals("N") || orderChangeDecision.equals("n"))) {
|
||||||
|
System.out.println("Bitte eine gültige Aussage treffen.\n");
|
||||||
|
System.out.print("Möchten Sie Einträge löschen? (Y/N) ");
|
||||||
|
orderChangeDecision = leser.nextLine();
|
||||||
|
|
||||||
|
if (orderChangeDecision.equals("Y") || orderChangeDecision.equals("y")) {
|
||||||
|
ArrayList<Order> changedOrderList = orderData.changeOrder(phoneNumber);
|
||||||
|
} else if (orderChangeDecision.equals("N") || orderChangeDecision.equals("n")) {
|
||||||
|
System.out.println("Daten werden nicht geändert.");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -19,7 +19,7 @@ public class GeneralMethods {
|
|||||||
* @author Madeleine Vigier
|
* @author Madeleine Vigier
|
||||||
*/
|
*/
|
||||||
public static String getDayNumberNew(String dateString) {
|
public static String getDayNumberNew(String dateString) {
|
||||||
//https://docs.oracle.com/javase/8/docs/api/java/time/format/DateTimeFormatter.html
|
//https://stackoverflow.com/questions/8746084/string-to-localdate
|
||||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd.MM.yyyy");
|
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
|
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);
|
LocalDate date = LocalDate.parse(dateString, formatter);
|
||||||
@@ -32,7 +32,7 @@ public class GeneralMethods {
|
|||||||
* The method getDayName() gets the weekday
|
* The method getDayName() gets the weekday
|
||||||
*
|
*
|
||||||
* @param dayNumber dayNumber e.g. 1 for Monday
|
* @param dayNumber dayNumber e.g. 1 for Monday
|
||||||
* @return weekday
|
* @return String weekday
|
||||||
* @author Madeleine Vigier
|
* @author Madeleine Vigier
|
||||||
*/
|
*/
|
||||||
public static String getDayName(int dayNumber) {
|
public static String getDayName(int dayNumber) {
|
||||||
@@ -55,110 +55,4 @@ public class GeneralMethods {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// /**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<String> 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<String> readData(String pathRead) {
|
|
||||||
// Path path = Paths.get(pathRead);
|
|
||||||
//
|
|
||||||
// try {
|
|
||||||
// List<String> rows = Files.readAllLines(path);
|
|
||||||
//
|
|
||||||
// if (pathRead.equals("menue.txt")) {
|
|
||||||
// ArrayList<String> 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<String> 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<String> 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<String> listToWrite){
|
|
||||||
// if (pathWrite.equals("users.txt")) {
|
|
||||||
//
|
|
||||||
// } else if (pathWrite.equals("orders.txt")) {
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -1,3 +1,5 @@
|
|||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The class Order is an object class that holds the constructor for order objects.
|
* The class Order is an object class that holds the constructor for order objects.
|
||||||
*
|
*
|
||||||
@@ -23,4 +25,23 @@ public class Order {
|
|||||||
public String toString(){
|
public String toString(){
|
||||||
return date+";"+user+";"+mealtype+";"+desserttype;
|
return date+";"+user+";"+mealtype+";"+desserttype;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Method create PDF is used to create a PDF document of the daily orders as well as the bills for each user
|
||||||
|
*
|
||||||
|
* This Method uses PDF Clown, the source code can be found at http://www.pdfclown.org
|
||||||
|
* PDF Clown is covered by LGPL, a copy of the LGPL can be found withing the documentation
|
||||||
|
*
|
||||||
|
* @param pathWrite determines which document should be created
|
||||||
|
* @param listToWrite determines the list which is to be used to create the document
|
||||||
|
* @author Sabine Gubitz
|
||||||
|
*/
|
||||||
|
|
||||||
|
public void createPDF (String pathWrite, ArrayList<String> listToWrite) {
|
||||||
|
if (pathWrite.equals("users.pdf")) {
|
||||||
|
|
||||||
|
} else if (pathWrite.equals("bills.pdf")) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user