HACC IT Online Training Application Design Specification Project
ANSWER
Section 5 – Class Design
Introduction: In Section 5 of this assignment, we will delve into the detailed class design for the ShoppingCart and ShoppingCartItem classes as part of the ITOT Case Study. This design process aligns with course objectives CO6 and CO9, focusing on the implementation of object-oriented models using UML concepts.
Section 5.1 – Class Diagram
For the detailed UML class design, we will establish a composition relationship between ShoppingCart and ShoppingCartItem, reflecting that when the ShoppingCart is empty, the ShoppingCartItem is also empty. The composition relationship implies that the lifetime of ShoppingCartItem is dependent on ShoppingCart. If ShoppingCart is destroyed, ShoppingCartItem instances within it are also destroyed.
Here’s a simplified representation of the class diagram:
ShoppingCart
- Attributes:
- items: List<ShoppingCartItem>
- totalCost: float
- Operations (Methods):
- addItem(item: ShoppingCartItem): void
- removeItem(item: ShoppingCartItem): void
- calculateTotalCost(): float
- getItems(): List<ShoppingCartItem>
- getTotalCost(): float
ShoppingCartItem
- Attributes:
- itemName: String
- quantity: int
- costPerItem: float
- totalCost: float
- Operations (Methods):
- updateItem(itemName: String, quantity: int, costPerItem: float): void
- getItemName(): String
- getQuantity(): int
- getCostPerItem(): float
- getTotalCost(): float
In the above class diagram:
- ShoppingCart has a composition relationship with ShoppingCartItem, denoted by the diamond-shaped symbol on the ShoppingCart end.
- ShoppingCart maintains a list of ShoppingCartItems and calculates the total cost.
- ShoppingCartItem represents an individual item in the cart, with attributes for its name, quantity, cost per item, and total cost.
- Operations are defined to add, remove, and calculate costs for items in the cart, and also to retrieve item details.
Section 5.2 – Discussion
The detailed class diagram provides a clear and concise representation of the ShoppingCart and ShoppingCartItem classes, their attributes, and operations. The composition relationship effectively models the containment of ShoppingCartItems within a ShoppingCart, ensuring that when a ShoppingCart is deleted, its associated items are also removed.
This design promotes modularity and encapsulation. The ShoppingCart encapsulates its item management logic, and the ShoppingCartItem encapsulates the attributes and operations related to individual items. This separation of concerns enhances maintainability and scalability.
The use of getter and setter methods enforces data encapsulation, allowing controlled access to class attributes. Additionally, the updateItem method in ShoppingCartItem provides a means to modify item details while maintaining consistency.
The composition relationship accurately reflects the real-world scenario where a shopping cart contains items, and the lifetime of items is tied to that of the cart. This design supports the use cases and sequence diagrams previously developed for the Manage Shopping Cart use case.
In conclusion, the detailed class design adheres to object-oriented principles, promoting a clean and robust architecture for the ITOT Case Study’s shopping cart system. This design is a crucial step towards implementing the software system and aligns with the course objectives related to software development processes and UML modeling.
QUESTION
Description
The purpose of this assignment is to continue our design modeling for the ITOT Case Study by creating detailed class designs for both ShoppingCart and ShoppingCartItem classes.
Course Objective (s)
CO6: Describe the software development process including the implementation of models and object oriented languages
CO9: Apply your knowledge of object oriented and UML concepts by designing and developing UML models
In this assignment you will develop a detailed design for both the ShoppingCart and ShoppingCartItem classes.
Follow the class design guidelines in your readings and use the appropriate use cases you have already developed for the project. Sequence diagrams include messages which are implemented as operations in classes. So, you will need to make certain that your messages in your sequence diagram are reflected in your detailed design. You will need the detailed steps of the Manage Shopping Cart use case and your sequence diagrams. Provide a description of your class design and justification for your decisions.
A class is often asked to provide the values of its attributes, so we usually create getter operations for each of the attributes while the attributes are made private. Like for Course we could create public operations like get.courseNo(), get.CourseTitle(), etc., and each of the attributes of Course would be made private so that any change is made through a publicly available operation(method). We also have operations that would set the values, such as set.CourseTitle(courseTitle), etc. where the parameter would be the new course title.
ShoppingCartItem would need operations/methods to manage the attributes it has like itemName, qty, costPerItem, and totalCost. So, you would have an update operation/method and the getter/setter operations/methods. It would also have the operation/method to calculate the total cost since it has all of the attributes and values to do this.
You will complete Sections 5 Class Design, 5.1 Detailed Class Diagram, and 5.2 Detailed Class Diagram Discussion in your Design Specification from last week.
Instructions
1. Review the resources listed at the end of this assignment.
2. Review the IT Online Training Project Requirements 2022R1 description, your Analysis Specification, and your Design Specification.
3. Complete the following:
Section 5
Add a small introduction to Section 5 – Class Design (less than 100 words).
Section 5.1 – Class Diagram
Develop a detailed UML class design for ShoppingCart and ShoppingCartItem and add it to Section 5.1 in your Design Specification. Remember that there is a composition relationship between ShoppingCart and ShoppingCartItem and this means that if the ShoppingCart is empty, then The ShoppingCartItem is also empty. See an example of Composition using Person and Job see the article Composition in Java Example at https://www.journaldev.com/1325/composition-in-java-example.
Section 5.2 – Discussion
Provide a discussion of the detailed class diagram (between 150 and 300 words).
Quick Resources
1. Both required readings will be helpful–Larman (2001), Blaha and Rumbaugh (2005).
2. For implementing UML Composition for Car and Engine see the article Association, Composition and Aggregation in Java at https://www.tutorialspoint.com/Association-Composition-and-Aggregation-in-Java
3. For another example of Composition using Person and Job see the article Composition in Java Example at https://www.journaldev.com/1325/composition-in-java-example