Corona Store โ SRS
ุงูู business: ู ุชุฌุฑ ุฅููุชุฑููู ูุจุณูููุช ูุดููููุงุชุฉ Corona.
- Corona ูุฑุฑุช ุชุนู ู online store ููุนู ูุงุก ูุทูุจูุง ู ูุชุฌุงุชูุง.
- ุงูุนู ูุงุก ูุฏูุนูุง ุจู credit card ุฃู cash on delivery.
- ุงูู ูู ุฉ: ุจูุงุก core business logic (UI later).
- ุงููุธุงู
ุจูุญุชูุธ ุจู list ู
ู products. ูู product:
code, name, unitPrice. - ุงูุนู ูู ูุนู ู order = list of items + quantity per product. ุงูู Order ููู delivery address.
- ูู order ูุงุฎุฏ automatic ID.
- ุงูู Order ููุถู open ูุญุฏ ู ุง ูุชุฏูุนุ ุจุนุฏูุง ูุจูู closed.
- Cash: ุงูุนู ูู ุจูุฏู ู ุจูุบ ู ุนูู โ ุงูู delivery person ูุฑุฌุน ุงูุจุงูู. ูู ุงูู cash insufficient โ message + order remains open.
- Credit Card: ู ู ูู ุชููู valid ยท expired ยท invalid ยท insufficient funds. ูู valid โ payment + user notified. ุบูุฑ ูุฏู โ error message.
Use Case Model
ุงูู Actor ุงูุฑุฆูุณู = Buyer. ุฏู ุงูู Use cases ุงูุฃุณุงุณูุฉ.
- โ Buyer โ main actorุ ุจูุนู ู orders ูุจูุฏูุน.
- โ Delivery Man? โ ู ุด actor ููู systemุ ูู ู ูุธู ุจูุณุชุฎุฏู external process. ุฅุฌุงุจุฉ ุงูุงู ุชุญุงู: Buyer is the only system actor.
Top Level
- UC1 โ Create Order
- UC2 โ Pay for Order
Specialized (Generalization)
- UC2a โ Pay by Cash (extends UC2)
- UC2b โ Pay by Credit Card (extends UC2)
Use Case Descriptions
ุงูู flow ุงูุชูุตููู ููู use case.
- Actor: Buyer
- Description: Buyer makes an order and decides products + quantities.
Main Flow
- Request to create order
- Give delivery address
- Generate automatic order ID
- Enter item and quantity
- Repeat step 4 to enter all items
- Create order and set status as
OPEN - Add to orders list
Exceptional Flow โ Cancel Order
- Request to cancel order
- ูู ุงูู order =
OPENโ ุงุญุฐูู. ุบูุฑ ูุฏู โ ุฑุณุงูุฉ Cannot cancel.
- Actor: Buyer
- Description: Pays for his order.
Main Flow
- Request to pay order
- Calculate order total
- Provide payment (cash/credit)
- ูู ูุฌุญ ุงูุฏูุน โ ุงูู order ูุจูู
CLOSED
- Request to pay order
- Calculate order total
- Give cash amount
- ูู cash >= total โ take payment
- Order =
CLOSED - Return change = cash โ total
- Display message
Exceptional Flow โ Insufficient Cash
1. Display message ยท 2. Order remains OPEN
- Request to pay order
- Calculate order total
- Give card details
- Validate card with Bank
- Deduct amount from card
- ูู ูุฌุญ ุงูุฏูุน โ Order =
CLOSED - Display message
Exceptional Flow โ Card Failure
ูู ุงููุงุฑุช INVALID, EXPIRED, or INSUFFICIENT โ Display message + Order remains OPEN.
Class Identification โ CRC Method
Find nouns โ candidate classes. ุญุฏุฏ responsibility ููู class ุจุงุณุชุฎุฏุงู CRC cards (Class-Responsibility-Collaboration).
- ุงูุฑุง ุงูู requirements ูุงุณุชุฎุฑุฌ nouns โ ูู noun ู ู ูู ูููู candidate class.
- ุญุฏุฏ responsibility ููู class.
- ุงุณุชุฎุฏู CRC cards (sticky notes) ููู candidate class.
- ุฅุฐุง ุงูู responsibilities ู ุง ุชุชูุนุด ูู card ูุงุญุฏ = ุงูู class ู ุญุชุงุฌ ูุชูุณู .
๐ฆ Order
Attributes
- delivery address
- client name
- date
- status
Operations
- create
- cancel order
- pay for order
- calculate total
Collaborates with
- OrderStatus (enum)
- Payment
- OrderDetail
- OrderManager
๐ช OrderManager
Attributes
- store name
- orderIDGenerator
- list of orders
- list of products
Operations
- create order
- cancel order
- pay for order
- add product
Collaborates with
- Order
- Products
๐ซ Product
Attributes
- code
- name
- unitPrice
Operations
- get info
Collaborates with
- OrderDetail
The Full Class Diagram
ุงุฌู ุน ูู ุงูู classes ูุงูู relationships.
1. OrderManager โ Order (1 : *)
OrderManager ุจูุนู ู aggregate ููู Orders (open diamond โ). ุงูู ุชุฌุฑ ุนูุฏู many orders.
2. OrderManager โ Product (1 : *)
ุงูู ุชุฌุฑ ุนูุฏู catalog of products. ุงูุนูุงูุฉ Aggregation.
3. Order โ OrderDetail (1 : *) โ Composition โ
OrderDetail ู ุง ููุฏุฑุด ููุฌุฏ ุจุฏูู Order (ูุจูุชู ุณุญ ู ุนุงู). ุฏู strong composition.
4. OrderDetail โ Product (* : 1)
ูู OrderDetail ุจูุดุงูุฑ ุนูู Product ูุงุญุฏ. ููุฐุง OrderDetails ู ู ูู ูุดุงูุฑูุง ุนูู ููุณ ุงูู Product.
5. Order โ Payment (1 : 1)
ูู order ุนูุฏู ุนูู ุงูุฃูุซุฑ Payment ูุงุญุฏ. ุฏู plain association.
6. Payment โ Cash, Credit (Generalization)
Payment ูู abstractุ ู Cash ู Credit ูู ุง subclasses.
7. Order โ OrderStatus (enum)
ุญูู ุงูู status ูู Order ุจูุดุงูุฑ ุนูู OrderStatus enum (OPEN, CLOSED).
8. Credit โ CardStatus (enum)
CardStatus = VALID, EXPIRED, INVALID, INSUFFICIENT.
public enum OrderStatus { OPEN, CLOSED; }
public enum CardStatus { VALID, EXPIRED, INVALID, INSUFFICIENT; }
public class Product {
private String code, name;
private float unitPrice;
}
public class OrderDetail {
private Product product;
private int quantity;
}
public class Order {
private int id;
private String deliveryAddress;
private OrderStatus status = OrderStatus.OPEN;
private ArrayList<OrderDetail> details = new ArrayList<>();
private Payment payment;
public void addProduct(Product p, int qty) { ... }
public float calculateTotal() { ... }
}
public abstract class Payment {
public abstract boolean processPayment(float total);
}
public class Cash extends Payment { ... }
public class Credit extends Payment {
private CardStatus status;
}
public class OrderManager {
private ArrayList<Order> orders;
private ArrayList<Product> products;
private int orderIDGenerator = 0;
public Order createOrder(String deliveryAddress) { ... }
}
Sequence Diagram โ Create Order
ุชุญููู UC1 ูู sequence ู ู method calls.
Actor โ OrderManager : createOrder(delivery_address)- OrderManager ูุนู
ู new
:Orderinstance ููุฑุฌุน order ref - Loop for each product:
Actor โ OrderManager : addProduct(orderID, prodID, quantity)- OrderManager creates new
OrderDetail - OrderManager โ Order :
addItem(orderDetail)
- OrderManager returns confirmation to Actor
// Step 1: Create order
Order myOrder = orderManager.createOrder("Cairo, Egypt");
// Step 2: Add items in loop
for (ProductInput p : userInputs) {
orderManager.addProduct(myOrder.getId(), p.code, p.quantity);
}
// Step 3: Pay for order
Cash payment = new Cash(100.0);
boolean success = orderManager.payForOrder(myOrder.getId(), payment);
Lessons for Question 2 โญ
ุงูู template ุงููู ุชุชุจุนู ูู Question 2 ูู ุงูู final.
- Read SRS carefully. ุนูู ุนูู ุงูู nouns ูุงูู actions.
- Identify actors โ ู ูู ุจูุชูุงุนู ู ุน ุงูู system ู ู ุจุฑููุ (1 mark)
- Identify use cases โ ูู actor ููุฏุฑ ูุนู ู ุฅููุ (4-6 marks)
- Draw use case diagram ู ุน ุงูุนูุงูุงุช (extend, include, generalization).
- Detail one use case โ main flow + exceptional flows (4-5 marks).
- Identify classes ู ู ุงูู nouns. ุตูููู ูู Domain / Control / Boundary.
- Draw class diagram ุจุงูู attributes, operations, relationships, multiplicities (8 marks).
- Draw sequence diagram ูู use case ูุงุญุฏ ูููุถุญ ุงูู methods ุงูู ุณุชุฎุฏู ุฉ (4 marks).
- Draw state diagram (ูู ู ุทููุจุ 2-4 marks) ูุญุงูุงุช object ู ุนูู.
Question 2 = ุญูุงูู 20+ marks. ุฎุฏ ููุง ุณุงุนุฉ ู ู ุงูู 2 ุณุงุนุงุช.
- 5 min โ ุงูุฑุฃ ุงูู requirements ูุญุฏุฏ ุงูู actors/use cases.
- 15 min โ Use case diagram + 1 detailed use case.
- 25 min โ Class diagram (ุงูุฃุทูู).
- 10 min โ Sequence diagram.
- 5 min โ State diagram ูู ู ุทููุจ.
- โ Methods ูู ุงูู sequence diagram ู ุด ู ูุฌูุฏุฉ ูู ุงูู class diagram.
- โ ูุณูุงู ุงูู multiplicities ุนูู ุงูู associations.
- โ ุงูุฎูุท ุจูู Aggregation โ ู Composition โ.
- โ ูุณูุงู ุญุงูุงุช OPEN/CLOSED ูู ุงูู state diagram.
- โ ุนุฏู ุงุณุชุฎุฏุงู ุนูุงูุฉ extend ููู conditional use cases (ู ุซูุงู Bad Credit).
- โ ุฑุณู ุงูู actors ูุฃููู classes โ ุงูู actors ุฎุงุฑุฌ ุงูู system boundary.
ููู Question 2: ุงูุฑุฃ ุงูุณุคุงู ู ุฑุชููุ ูุญุฏุฏ ุงูู keywords ุงูุฎุงุตุฉ ุจุงูู relationships (e.g., consists of = composition, has many = aggregation, is a kind of = generalization, uses = association). ูู keyword ุจูุฏูู ุนูู relation ู ุนููุฉ.
Cheat Sheet
Question 2 template + ุฃูู ู ูุงููู Corona Store.