0% found this document useful (0 votes)
5 views5 pages

Programming II Unit 2 Assignment

The document presents an assignment for a Computer Programming II course, focusing on the implementation of an e-commerce system in Java. It includes class definitions for Product, Customer, and Order, demonstrating encapsulation and the use of packages. Additionally, it references educational materials on Java programming and package organization.

Uploaded by

keibro123
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)
5 views5 pages

Programming II Unit 2 Assignment

The document presents an assignment for a Computer Programming II course, focusing on the implementation of an e-commerce system in Java. It includes class definitions for Product, Customer, and Order, demonstrating encapsulation and the use of packages. Additionally, it references educational materials on Java programming and package organization.

Uploaded by

keibro123
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

Computer Programming II Assignment Unit 2

Keith R. Brown

Department of Science, University of the People

CS 1103-01 AY2026-T3

Instructor Alejandro Lara

February 2nd, 2026


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;
}

// Getters and setters for product attributes

// Other product-related methods


}

public class Customer {


private int customerID;
private String name;
private ShoppingCart cart;

public Customer(int customerID, String name) {


[Link] = customerID;
[Link] = name;
[Link] = new ShoppingCart();
}

// Methods to add and remove products from the shopping cart,


calculate total cost, and place orders

// Other customer-related methods


}

package [Link];

public class Order {


private int orderID;
private Customer customer;
private List<Product> products;
private double orderTotal;

public Order(int orderID, Customer customer, List<Product>


products) {
[Link] = orderID;
[Link] = customer;
[Link] = products;
[Link] = calculateOrderTotal();
}

// Methods to generate order summaries, update order status,


and manage order information

// Other order-related methods


}

// Main program
import [Link];
import [Link];
import [Link];

public class Main {


public static void main(String[] args) {
// Demonstrate the use of packages and classes
Product product1 = new Product(1, "Product 1", 50.0);
Customer customer1 = new Customer(1, "John Doe");
List<Product> products = new ArrayList<>();
[Link](product1);
Order order1 = new Order(1, customer1, products);

// Other operations and demonstrations


}
}

This example demonstrates the organization of classes into packages, the use of import

statements, and the implementation of an e-commerce system in Java with proper encapsulation

and data hiding.


References:

Eck, D. J. (2022). Introduction to programming using java version 9, JavaFX edition.

Licensed under CC 4.0. [Link]

Packages in Java. (n.d.). Board Infinity.

[Link]

Samoylov, N. (2018). Introduction to programming: Learn to program in java with

data structures, algorithms, and logic. Packt Publishing, Limited.

You might also like