0% found this document useful (0 votes)
7 views3 pages

E-commerce Order Management System

The document contains Java classes for an e-commerce system, including Order, Customer, and Product classes. The Order class manages order details and generates summaries, while the Customer class handles shopping cart operations. The Product class defines product attributes and methods for accessing product information.

Uploaded by

robert
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views3 pages

E-commerce Order Management System

The document contains Java classes for an e-commerce system, including Order, Customer, and Product classes. The Order class manages order details and generates summaries, while the Customer class handles shopping cart operations. The Product class defines product attributes and methods for accessing product information.

Uploaded by

robert
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Robert Banda

Programming Assignment 2

package [Link];
import [Link];
import [Link];
import [Link];
public class Order {
private int orderID;
private Customer customer;
private List<Product> products;
public Order(int orderID, Customer customer, List<Product> products)
{
[Link] = orderID;
[Link] = customer;
[Link] = products;
}
public int getOrderID() {
return orderID;
}
public Customer getCustomer() {
return customer;
}
public List<Product> getProducts() {
return products;
}
public double getOrderTotal() {
double total = 0;
for (Product product : products) {
total += [Link]();

return total;
}
public String generateOrderSummary() {
StringBuilder summary = new StringBuilder();
[Link]("Order ID: ").append(orderID).append("\n");
[Link]("Customer: ").append([Link]()).append("\
n");
[Link]("Products in the order:\n");
for (Product product : products) {
[Link]("- ").append([Link]()).append("
($").append([Link]()).append(")\n");
}
[Link]("Total cost: $").append(getOrderTotal());
return [Link]();
}
}
package [Link];
import [Link];
import [Link];
public class Customer {
private int customerID;
private String name;
private List<Product> shoppingCart;
public Customer(int customerID, String name) {
[Link] = customerID;
[Link] = name;
[Link] = new ArrayList<>();
}
public void addToCart(Product product) {
[Link](product);
}
public void removeFromCart(Product product) {
[Link](product);
}
public double calculateTotalCost() {
double totalCost = 0;
for (Product product : shoppingCart) {
totalCost += [Link]();
}
return totalCost;
}
public List<Product> getShoppingCart() {
return shoppingCart;
}
public String getName() {
return name;
}
}
package [Link];
public class Product {
private int productID;
private String name;
private double price;
public Product(int productID, String name, double price) {
[Link] = productID;
[Link] = name;
[Link] = price;
}
public int getProductID() {
return productID;
}
public void setProductID(int productID) {
[Link] = productID;
}
public String getName() {
return name;
}
}

You might also like