2024-10-14 19:06:53 +02:00
|
|
|
import java.util.ArrayList;
|
|
|
|
|
|
|
|
public class OrderSystem {
|
|
|
|
private StorageManager systemManager;
|
|
|
|
private ArrayList<Client> systemClients;
|
2024-10-18 15:17:59 +02:00
|
|
|
<<<<<<< HEAD
|
2024-10-15 06:17:06 +02:00
|
|
|
public OrderSystem(StorageManager manager) {
|
2024-10-14 19:06:53 +02:00
|
|
|
this.systemManager = manager;
|
2024-10-15 06:17:06 +02:00
|
|
|
this.systemClients = new ArrayList<Client>();
|
2024-10-18 15:17:59 +02:00
|
|
|
=======
|
2024-10-14 19:12:15 +02:00
|
|
|
public OrderSystem(StorageManager manager, ArrayList<Client> clients) {
|
|
|
|
this.systemManager = manager;
|
|
|
|
this.systemClients = clients;
|
2024-10-18 15:17:59 +02:00
|
|
|
>>>>>>> 89bb3a674e4304644c37109ed5a608b97926deb9
|
2024-10-14 19:06:53 +02:00
|
|
|
}
|
|
|
|
public void addProduct(Product product) {
|
|
|
|
this.systemManager.addProduct(product);
|
|
|
|
}
|
|
|
|
public void addClient(Client client) {
|
|
|
|
this.systemClients.add(client);
|
|
|
|
}
|
|
|
|
public Client getClientByID(int id) {
|
|
|
|
for (Client client : this.systemClients) {
|
|
|
|
if (client.getID() == id) {
|
|
|
|
return client;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return new Client("", "");
|
|
|
|
}
|
|
|
|
public void createOrder(int id, Order order) {
|
|
|
|
this.getClientByID(id).addOrder(order);
|
|
|
|
}
|
|
|
|
public ArrayList<Client> getClients() {
|
|
|
|
return this.systemClients;
|
|
|
|
}
|
|
|
|
public Product getProductByID(int id) {
|
|
|
|
for (Product product : this.systemManager.getStorage()) {
|
|
|
|
if (product.getID() == id) {
|
|
|
|
return product;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return new Product(-1, "", 0, 0);
|
|
|
|
}
|
|
|
|
public StorageManager getManager() {
|
|
|
|
return this.systemManager;
|
|
|
|
}
|
|
|
|
public void showClients() {
|
|
|
|
for (Client client : this.systemClients) {
|
|
|
|
System.out.println(client.toString());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
public void showProducts() {
|
|
|
|
if (this.systemManager.getStorage().isEmpty()) {
|
|
|
|
System.out.println("No products exist");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
for (Product product : this.systemManager.getStorage()) {
|
|
|
|
System.out.println("ID: " + product.getID() + ", Name: " + product.getName() + ", Price: " + product.getPrice() + ", Amount: " + product.getAmount());
|
|
|
|
}
|
|
|
|
}
|
2024-10-18 15:17:59 +02:00
|
|
|
<<<<<<< HEAD
|
|
|
|
}
|
|
|
|
=======
|
2024-10-15 06:17:06 +02:00
|
|
|
}
|
2024-10-18 15:17:59 +02:00
|
|
|
>>>>>>> 89bb3a674e4304644c37109ed5a608b97926deb9
|