You are on page 1of 2

public class Product {

private String name;


private double price;
// Other product properties and getters/setters

// Constructor
public Product(String name, double price) {
this.name = name;
this.price = price;
}
}

public class ProductListing {


private List<Product> products;

public ProductListing() {
products = new ArrayList<>();
}

public void addProduct(String name, double price) {


Product newProduct = new Product(name, price);
products.add(newProduct);
}

public List<Product> getProducts() {


return products;
}
}

public class Order {


private User user;
private List<Product> products;
// Other order properties and getters/setters

// Constructor
public Order(User user, List<Product> products) {
this.user = user;
this.products = products;
}
}

public class OrderProcessing {


private List<Order> orders;

public OrderProcessing() {
orders = new ArrayList<>();
}

public void placeOrder(User user, List<Product> products) {


Order newOrder = new Order(user, products);
orders.add(newOrder);
// Process order logic
}

public List<Order> getOrders() {


return orders;
}
}

You might also like