Initial commit: Complete TDD workshop materials
- Workshop documentation (WORKSHOP_PLAN, FACILITATOR_GUIDE, etc.) - FizzBuzz kata with demo script (git history to be recreated) - Password Validator kata with demo script and solution - Shopping Cart kata with demo script and solution - Setup guide and TDD reference card for participants
This commit is contained in:
commit
c3355063f2
26 changed files with 4725 additions and 0 deletions
46
shopping_cart/lib/shopping_cart.dart
Normal file
46
shopping_cart/lib/shopping_cart.dart
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
// TODO: Implement ShoppingCart using TDD.
|
||||
//
|
||||
// Domain rules (implement one at a time, test first!):
|
||||
// 1. Add an item (name, price, quantity) to the cart
|
||||
// 2. Get the subtotal (sum of price × quantity for all items)
|
||||
// 3. Remove an item by name
|
||||
// 4. Get total item count (sum of all quantities)
|
||||
// 5. Apply a percentage discount to the subtotal (e.g. 10% off)
|
||||
// 6. Items with zero or negative price are rejected
|
||||
//
|
||||
// CartItem is a Value Object — immutable, validated at construction.
|
||||
// ShoppingCart is stateful — it accumulates items across calls.
|
||||
|
||||
class CartItem {
|
||||
final String name;
|
||||
final double price;
|
||||
final int quantity;
|
||||
|
||||
CartItem({required this.name, required this.price, required this.quantity}) {
|
||||
// TODO: validate price > 0 and quantity > 0
|
||||
}
|
||||
}
|
||||
|
||||
class ShoppingCart {
|
||||
// TODO: implement
|
||||
|
||||
void addItem(CartItem item) {
|
||||
throw UnimplementedError();
|
||||
}
|
||||
|
||||
void removeItem(String name) {
|
||||
throw UnimplementedError();
|
||||
}
|
||||
|
||||
double subtotal() {
|
||||
throw UnimplementedError();
|
||||
}
|
||||
|
||||
int itemCount() {
|
||||
throw UnimplementedError();
|
||||
}
|
||||
|
||||
double totalAfterDiscount(double discountPercent) {
|
||||
throw UnimplementedError();
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue