0% found this document useful (0 votes)
18 views

System FinalASM

Uploaded by

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

System FinalASM

Uploaded by

leminh11072005
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Product Management System

1. Introduction
The system is designed to manage products, brands, and categories in a retail environment. It will
allow users to perform CRUD operations (Create, Read, Update, Delete) on these entities, ensuring
data integrity and ease of use. The system will also ensure that validations are implemented to
maintain consistency in the stored information.
2. Functional Requirements
2.1 Function 1: Create Product (2 Marks)
The system requires input for creating a product. The information to be provided includes:
• Product ID (int): A unique identifier for the product.
• Product Name (String): A string representing the name of the product.
• Brand ID (int): A reference to the brand's ID.
• Category ID (int): A reference to the category's ID.
• Model Year (short): The year the product model was released.
• List Price (float): The price of the product.
Validation Rules:
1. Product ID must be unique: The system checks if the provided Product ID already exists
in the list of products. If it does, the system prompts the user to enter a different ID.
2. Product Name must be at least three characters long: The system ensures that the
product name has a minimum length of 3 characters. If the name is shorter than this, an error
message is shown.
3. Model Year must be a valid year between 2000 and current day: The system validates
that the year provided is within this range.
4. List Price should be a positive decimal value: The system ensures that the price is greater
than zero and is a valid decimal number.
5. Brand ID must exist in the list of brands: The system checks if the provided Brand ID
matches one of the IDs in the list of brands stored in ArayList. If no match is found, an error
is raised, and the user is prompted to enter a valid brand.
6. Category ID must exist in the list of categories: Similarly, the system ensures that the
Category ID exists in the list of categories. If the category doesn't exist, the user is
prompted to choose a valid category.
Implementation Considerations:
• To perform these checks, the system will need access to two additional lists:
◦ A list of Brands, which contains all valid brand IDs.
◦ A list of Categories, which contains all valid category IDs.
• The system will iterate through these lists to validate that the provided Brand ID and
Category ID exist.
• If any validation rule is not satisfied, the system will display an appropriate error message
and prompt the user to re-enter the data.
Example Workflow for Product Creation
Prompt User for Input:
• Enter Product ID: 1001
• Enter Product Name: Laptop Pro
• Enter Brand ID: 5 (System checks if Brand ID 5 exists in the brand list.)
• Enter Category ID: 3 (System checks if Category ID 3 exists in the category list.)
• Enter Model Year: 2021
• Enter List Price: 999.99
Validation:
• If Product ID already exists → Error: "Product ID already exists, please provide a unique
ID."
• If Product Name is too short → Error: "Product Name must be at least 3 characters long."
• If Model Year is not within 2000-2024 → Error: "Model Year must be between 2000 and
2024."
• If List Price is non-positive → Error: "List Price must be greater than zero."
• If Brand ID does not exist → Error: "Invalid Brand ID, please select a valid brand."
• If Category ID does not exist → Error: "Invalid Category ID, please select a valid
category."
Successful Product Creation:
• If all validations pass, the product is added to the system, and a success message is
displayed: "Product created successfully."
2.2 Function 2: Display All Products (2 Marks)
• The system will display a list of all products in the ArrayList, sorted alphabetically by
product name.
• If two products have the same name, they will be sorted by product ID in ascending order.
2.3 Function 3: Update Product (2 Marks)
• The user will provide the product ID of the product to be updated.
• If the product does not exist, the system will show a notification saying "Product does not
exist."
• If the product exists, the user can edit any of the remaining details (Product Name, Brand
ID, Category ID, Model Year, or List Price).
• The system will only update fields that are provided with new data. Fields that are left blank
will retain their previous values.
The system will show the result of the update as either "Update successful" or "Update failed"
based on the operation's outcome.

2/5


2.4 Function 4: Delete Product (1 Mark)
• The user will enter the product ID of the product they wish to delete.
• If the product does not exist, the system will show a message saying "Product does not
exist."
• If the product exists, the system will prompt for confirmation before deleting it. Upon
successful deletion, the system will show a "Delete successful" message.
2.5 Function 5: Find Product by Name (2 Marks)
• The system will allow the user to search for products based on a part of their name.
• The search will return all products that contain the search string in their name.
• If no matching products are found, the system will display the message "No products
found."
The list of matching products will be displayed in alphabetical order by product name.
2.6 Bonus (1 Mark)
• The system will have the ability to save the product data to a file for future retrieval. This
allows the data to persist beyond the lifetime of the current session.
3. UML Class Diagram

Brand Product
- brandID: int - productID: int
- brandName: String - productName: String
+ getBrandID(): int - brandID: int
+ setBrandID(id:int): void - categoryID: int
+ getBrandName(): String - modelYear: short
+ setBrandName(name:String): void - listPrice: float
+ toString(): String + getProductID(): int
+ setProductID(id:int): void
Category + getProductName(): String
- categoryID: int + setProductName(name:String): void
- categoryName: String + getBrandID(): int
+ getCategoryID(): int + setBrandID(id:int): void
+ setCategoryID(id:int): void + getCategoryID(): int
+ getCategoryName(): String + setCategoryID(id:int): void
+ setCategoryName(name:String): void + getModelYear(): short
+ toString(): String + setModelYear(year:short): void
+ getListPrice(): float
+ setListPrice(price:float): void
+ toString(): String

3/5


<<Interface>> ProductOperations
+ createProduct(Product product): void
+ updateProduct(int productID, Product product): void
+ deleteProduct(int productID): boolean
+ findProductByName(String name): List<Product>
+ listAllProducts(): List<Product>

ProductManagement
- products: ArrayList<Product>
- brands: ArrayList<Brand>
- categories: ArrayList<Category>
+ createProduct(Product product): void
+ updateProduct(int productID, Product product): void
+ deleteProduct(int productID): boolean
+ findProductByName(String name): List<Product>
+ listAllProducts(): List<Product>
+ main(args: String[]): void

4. Initial Data for List of Brands and Categories


4.1 List of Brands
1. List<Brand> brands = new ArrayList<>();
2. brands.add(new Brand(1, "Apple"));
3. brands.add(new Brand(2, "Samsung"));
4. brands.add(new Brand(3, "Sony"));
5. brands.add(new Brand(4, "LG"));
6. brands.add(new Brand(5, "Dell"));
7. brands.add(new Brand(6, "HP"));
8. brands.add(new Brand(7, "Lenovo"));
9. brands.add(new Brand(8, "Asus"));
10. brands.add(new Brand(9, "Microsoft"));
11. brands.add(new Brand(10, "Google"));

4.2 List of Categories


1. List<Category> categories = new ArrayList<>();
2. categories.add(new Category(1, "Smartphones"));
3. categories.add(new Category(2, "Laptops"));
4. categories.add(new Category(3, "Tablets"));
5. categories.add(new Category(4, "Wearables"));
6. categories.add(new Category(5, "Monitors"));
7. categories.add(new Category(6, "Printers"));
8. categories.add(new Category(7, "Accessories"));
9. categories.add(new Category(8, "Software"));
10. categories.add(new Category(9, "Gaming Consoles"));
11. categories.add(new Category(10, "Home Appliances"));

4/5


5. User Interface Requirements
• The system will be a console-based application, with a menu-driven interface. The user will
be presented with a menu that allows them to select from the available functions (Create,
Read, Update, Delete, and Search).
• Sample Main Menu:
1. Create Product
2. Display All Products
3. Update Product
4. Delete Product
5. Find Product by Name
6. Save to file (Optional)
7. Exit

-- THE END --

5/5

You might also like