Update Technikladen/TechStore.java

Removed package line
This commit is contained in:
Igor Bartkowski 2024-10-14 19:08:48 +02:00
parent a5fea77649
commit ed9f84a466

@ -1,113 +1,111 @@
package tech_store; import java.util.ArrayList;
import java.util.Scanner;
import java.util.ArrayList;
import java.util.Scanner; public class TechStore {
public static void p(String input) {
public class TechStore { System.out.print(input);
public static void p(String input) { }
System.out.print(input); public static void main(String[] args) {
} StorageManager manager = new StorageManager(new ArrayList<Product>());
public static void main(String[] args) { OrderSystem system = new OrderSystem(manager, new ArrayList<Client>());
StorageManager manager = new StorageManager(new ArrayList<Product>()); Scanner scnr = new Scanner(System.in);
OrderSystem system = new OrderSystem(manager, new ArrayList<Client>()); while (true) {
Scanner scnr = new Scanner(System.in); p("\nInput mode: ");
while (true) { String input = scnr.nextLine();
p("\nInput mode: "); if (input.equals("8")) {
String input = scnr.nextLine(); break;
if (input.equals("8")) { }
break; switch (Integer.parseInt(input)) {
} case 1: {
switch (Integer.parseInt(input)) { p("Name: ");
case 1: { String name = scnr.nextLine();
p("Name: "); p("E-Mail: ");
String name = scnr.nextLine(); String email = scnr.nextLine();
p("E-Mail: "); system.addClient(new Client(name, email));
String email = scnr.nextLine(); break;
system.addClient(new Client(name, email)); }
break; case 2: {
} ArrayList<Client> clients = system.getClients();
case 2: { if (clients.isEmpty()) {
ArrayList<Client> clients = system.getClients(); System.out.println("No clients found");
if (clients.isEmpty()) { break;
System.out.println("No clients found"); }
break; for (Client client : clients) {
} System.out.println(client.toString());
for (Client client : clients) { }
System.out.println(client.toString()); break;
} }
break; case 3: {
} p("ID: ");
case 3: { int id = Integer.parseInt(scnr.nextLine());
p("ID: "); p("Name: ");
int id = Integer.parseInt(scnr.nextLine()); String name = scnr.nextLine();
p("Name: "); p("Price: ");
String name = scnr.nextLine(); int price = Integer.parseInt(scnr.nextLine());
p("Price: "); p("Amount: ");
int price = Integer.parseInt(scnr.nextLine()); int amt = Integer.parseInt(scnr.nextLine());
p("Amount: "); system.addProduct(new Product(id, name, price, amt));
int amt = Integer.parseInt(scnr.nextLine()); break;
system.addProduct(new Product(id, name, price, amt)); }
break; case 4: {
} system.showProducts();
case 4: { break;
system.showProducts(); }
break; case 5: {
} system.showProducts();
case 5: { p("ID: ");
system.showProducts(); int id = Integer.parseInt(scnr.nextLine());
p("ID: "); p("Amount: ");
int id = Integer.parseInt(scnr.nextLine()); int amt = Integer.parseInt(scnr.nextLine());
p("Amount: "); manager.increaseStorage(id, amt);
int amt = Integer.parseInt(scnr.nextLine()); break;
manager.increaseStorage(id, amt); }
break; case 6: {
} system.showClients();
case 6: { p("ID: ");
system.showClients(); int clientID = Integer.parseInt(scnr.nextLine());
p("ID: "); p("Date: ");
int clientID = Integer.parseInt(scnr.nextLine()); String date = scnr.nextLine();
p("Date: "); Order order = new Order(clientID, date);
String date = scnr.nextLine(); system.showProducts();
Order order = new Order(clientID, date); while (true) {
system.showProducts(); p("ID: ");
while (true) { String id_str = scnr.nextLine();
p("ID: "); if (id_str.equals("exit")) {
String id_str = scnr.nextLine(); break;
if (id_str.equals("exit")) { }
break; int id = Integer.parseInt(id_str);
} p("Amount: ");
int id = Integer.parseInt(id_str); int amt = Integer.parseInt(scnr.nextLine());
p("Amount: "); if (manager.getProductByID(id).getAmount() < amt) {
int amt = Integer.parseInt(scnr.nextLine()); System.out.println("Amount chosen too high");
if (manager.getProductByID(id).getAmount() < amt) { continue;
System.out.println("Amount chosen too high"); }
continue; order.addEntry(new OrderEntry(system.getProductByID(id), amt));
} }
order.addEntry(new OrderEntry(system.getProductByID(id), amt)); system.createOrder(clientID, order);
} break;
system.createOrder(clientID, order); }
break; case 7: {
} system.showClients();
case 7: { p("ID: ");
system.showClients(); int id = Integer.parseInt(scnr.nextLine());
p("ID: "); int n = 0;
int id = Integer.parseInt(scnr.nextLine()); for (Order order : system.getClientByID(id).getOrders()) {
int n = 0; System.out.println((n++) + order.toString());
for (Order order : system.getClientByID(id).getOrders()) { }
System.out.println((n++) + order.toString()); p("ID: ");
} int order_id = Integer.parseInt(scnr.nextLine());
p("ID: "); System.out.println(system.getClientByID(id).getOrders().get(order_id).createReceipt());
int order_id = Integer.parseInt(scnr.nextLine()); break;
System.out.println(system.getClientByID(id).getOrders().get(order_id).createReceipt()); }
break; case 8: {
} return;
case 8: { }
return; }
} }
} }
} }
}
}