Download as pdf or txt
Download as pdf or txt
You are on page 1of 9

URDANETA CITY

UNIVERSITY COLLEGE OF INFORMATION AND


Owned and operated by the City Government of Urdaneta
TECHNOLOGY EDUCATION

in
INTEGRATIVE PROGRAMMING & TECHNOLOGIES

Submitted to:

ARLYN L. AQUINO
Instructor

Submitted by:

MONTERO, ARRONNE MARC A.


BSIT II

December 2023

(075) 600 - 1507


Bright future starts here San Vicente West, Urdaneta City, Pangasinan
ucu.edu.ph | univpresidentofficial@gmail.com
URDANETA CITY
UNIVERSITY COLLEGE OF INFORMATION AND
Owned and operated by the City Government of Urdaneta
TECHNOLOGY EDUCATION

Objectives: Apply knowledge of Object-Oriented Programming and all of the topics for the whole
semester.
Task: Create a Mini-System Project using Object-Oriented Programming.
▪ Choose a Mini-System:
- Select a mini-system to develop, such as a simple ordering system, inventory
management system, or any other relevant system that involves multiple interacting
entities.
▪ Use OOP Principles:
- Apply Object-Oriented Programming principles, including encapsulation, inheritance,
and polymorphism, to design and structure your classes.
▪ Create Class Methods:
- Implement methods within your classes to represent actions that can be performed
on objects. For example, if you're building an ordering system, you might have
methods like placeOrder(), calculateTotal(), etc.

Tools: PC/Mobile Phone, Text Editor/Command Prompt/IDE


Instructions for Submission:
▪ Submit your output in .pdf format to our Google Classroom.
▪ File name: Lastname, Firstname-Final-Project-IPT
▪ Deadline: DECEMBER 12, 2023 8:00 PM

Additional Announcement:
▪ Be prepared to present your project to the class, explaining the concepts, processes and
functionality.

(075) 600 - 1507


Bright future starts here San Vicente West, Urdaneta City, Pangasinan
ucu.edu.ph | univpresidentofficial@gmail.com
URDANETA CITY
UNIVERSITY COLLEGE OF INFORMATION AND
Owned and operated by the City Government of Urdaneta
TECHNOLOGY EDUCATION

Title: Shopping System

Description Shopping System is an Object-Oriented Program that simulates an online shopping


: experience. It consists of several classes that model the entities involved in the
system, such as items, products, categories, orders, and the shopping system itself.
The “Item” class serves as the base class, with “Product” and “Category” classes
extending it to represent specific types of items.

The purpose of this mini-system is to simulate a basic shopping experience. Users


can select a category, choose a product from that category, specify the quantity,
and place an order. The system calculates the total price of the order and displays
the order details. The user can continue shopping or exit the program.

(075) 600 - 1507


Bright future starts here San Vicente West, Urdaneta City, Pangasinan
ucu.edu.ph | univpresidentofficial@gmail.com
URDANETA CITY
UNIVERSITY COLLEGE OF INFORMATION AND
Owned and operated by the City Government of Urdaneta
TECHNOLOGY EDUCATION

The first process of the code displayed a list of product categories available for shopping. Each category is listed
with a corresponding number. Categories include "Electronics" (1), "Clothing" (2), and "Shoes" (3). The user is
prompted to select by entering the number they are interested in.

(075) 600 - 1507


Bright future starts here San Vicente West, Urdaneta City, Pangasinan
ucu.edu.ph | univpresidentofficial@gmail.com
URDANETA CITY
UNIVERSITY COLLEGE OF INFORMATION AND
Owned and operated by the City Government of Urdaneta
TECHNOLOGY EDUCATION

In the second process, after the user selects a category, the program displays the products available in the
category selected by the user. The program displays the products that are available in the category of "clothes,"
which are "T-shirts," short pants, and jeans. After the products are displayed, the user selects and enters the
number they are interested in.

(075) 600 - 1507


Bright future starts here San Vicente West, Urdaneta City, Pangasinan
ucu.edu.ph | univpresidentofficial@gmail.com
URDANETA CITY
UNIVERSITY COLLEGE OF INFORMATION AND
Owned and operated by the City Government of Urdaneta
TECHNOLOGY EDUCATION

In the third process, after the user selects and enters the number of the product they want to buy, they will be
asked the quantity they would like to purchase. After they enter the quantity of the product, the total price of
the user's order will be displayed, and after the total price is displayed, the user will be asked if they want to
continue shopping or not. If yes, the user will repeat the selection from the first process, and if not, the customer
will be told, "Please proceed to payment. Thank you for shopping with us."

(075) 600 - 1507


Bright future starts here San Vicente West, Urdaneta City, Pangasinan
ucu.edu.ph | univpresidentofficial@gmail.com
URDANETA CITY
UNIVERSITY COLLEGE OF INFORMATION AND
Owned and operated by the City Government of Urdaneta
TECHNOLOGY EDUCATION

Source Code:
PASTE HERE YOUR SOURCE CODE

import java.util.Scanner;

class Item {
protected String name;

public Item(String name) {


this.name = name;
}

public String getName() {


return name;
}
}

class Product extends Item {


private double price;

public Product(String name, double price) {


super(name);
this.price = price;
}

public double getPrice() {


return price;
}
}

class Category extends Item {


private Product[] products;

public Category(String name, Product[] products) {


super(name);
this.products = products;
}

public Product[] getProducts() {


return products;
}
}

class Order {
private Product product;
private int quantity;

public Order(Product product, int quantity) {


this.product = product;
this.quantity = quantity;
}

(075) 600 - 1507


Bright future starts here San Vicente West, Urdaneta City, Pangasinan
ucu.edu.ph | univpresidentofficial@gmail.com
URDANETA CITY
UNIVERSITY COLLEGE OF INFORMATION AND
Owned and operated by the City Government of Urdaneta
TECHNOLOGY EDUCATION

public double calculateTotalPrice() {


return product.getPrice() * quantity;
}

public String getOrderDetails() {


String formattedTotalPrice = String.format("₱%,d", (int) calculateTotalPrice());
return "The total price of your order is: " + formattedTotalPrice +
"\nPlease proceed to payment. Thank you for shopping with us!";
}
}

class ShoppingSystem {
private Category[] categories;

public ShoppingSystem(Category[] categories) {


this.categories = categories;
}

public void displayCategories() {


System.out.println("Categories:");
for (int i = 0; i < categories.length; i++) {
System.out.println((i + 1) + ". " + categories[i].getName());
}
}

public void displayProducts(Category category) {


System.out.println("Products in " + category.getName() + ":");
Product[] products = category.getProducts();
for (int i = 0; i < products.length; i++) {
System.out.println((i + 1) + ". " + products[i].getName() + " - ₱" + String.format("%,d",
(int) products[i].getPrice()));
}
}
}

public class Main {


public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);

// Create categories and products


Category electronics = new Category("Electronics",
new Product[]{new Product("Laptop", 75599), new Product("Aircon", 80999), new
Product("Washing Machine", 23595), new Product("Smartphone", 9899)});
Category clothing = new Category("Clothing",
new Product[]{new Product("T-Shirt", 499), new Product("Short Pants", 199), new
Product("Jeans", 799)});
// Adding Shoes category
Category shoes = new Category("Shoes",
new Product[]{new Product("Sports Shoes", 8800), new Product("Running Shoes",
4500), new Product("Casual Shoes", 2500)});

(075) 600 - 1507


Bright future starts here San Vicente West, Urdaneta City, Pangasinan
ucu.edu.ph | univpresidentofficial@gmail.com
URDANETA CITY
UNIVERSITY COLLEGE OF INFORMATION AND
Owned and operated by the City Government of Urdaneta
TECHNOLOGY EDUCATION

Category[] categories = {electronics, clothing, shoes};

// Initialize the shopping system


ShoppingSystem shoppingSystem = new ShoppingSystem(categories);

char continueShopping;

do {
int selectedCategory, selectedProductIndex, quantity;

// Display categories
shoppingSystem.displayCategories();
System.out.println("Enter the category number:");
selectedCategory = scanner.nextInt() - 1;

if (selectedCategory >= 0 && selectedCategory < categories.length) {


// Display products in the selected category
shoppingSystem.displayProducts(categories[selectedCategory]);
System.out.println("Select a product number:");
selectedProductIndex = scanner.nextInt() - 1;

if (selectedProductIndex >= 0 && selectedProductIndex <


categories[selectedCategory].getProducts().length) {
// Get the selected product
Product selectedProduct =
categories[selectedCategory].getProducts()[selectedProductIndex];

System.out.println("How many would you like to order:");


quantity = scanner.nextInt();

// Create an order and display details


Order order = new Order(selectedProduct, quantity);
System.out.println(order.getOrderDetails());
} else {
System.out.println("Invalid product selection. Please try again.");
}
} else {
System.out.println("Invalid category selection. Please try again.");
}

System.out.println("Do you want to continue shopping? (y/n)");


continueShopping = scanner.next().charAt(0);

} while (continueShopping == 'y' || continueShopping == 'Y');

System.out.println("Thank you for shopping with us. Have a great day!");


scanner.close();
}
}

(075) 600 - 1507


Bright future starts here San Vicente West, Urdaneta City, Pangasinan
ucu.edu.ph | univpresidentofficial@gmail.com

You might also like