Patterns: Singleton (AppConfig, DatabaseManager) · Decorator (toppings) · Strategy (pricing: No/Student/HappyHour/BestPrice/Voucher)
UI: Swing (base/toppings/strategy/voucher + giỏ hàng, realtime subtotal/total, lưu DB)
DB: SQLite (file database/smartbrew.db), DAO + schema.sql
Tests: JUnit 5 (unit + integration), JaCoCo (>=75% coverage), SpotBugs, Spotless
Build: Maven Shade → target/smartbrew.jar
SmartBrew/
source/src/main/java/com/designpatterns/smartbrew/...
source/src/test/java/com/designpatterns/smartbrew/...
source/src/main/resources/application.properties
database/{schema.sql, seed.sql, smartbrew.db}
thuc-thi/{run-ui.bat, run-ui.sh, run-cli.bat, run-cli.sh}
docs/{ARCHITECTURE.md, TEST-PLAN.md, DEMO-SCRIPT.md}
pom.xml
# 1) Build + test
mvn clean package
mvn -q -DskipTests=false test
# 2) Chạy UI (main class = AppUI đã cấu hình trong shade)
java -jar target/smartbrew.jar
# 3) (Tuỳ chọn) chạy CLI demo
java -cp target/smartbrew.jar com.designpatterns.smartbrew.app.App
# 4) Đóng gói thực thi
copy target/smartbrew.jar thuc-thi/
# Windows:
thuc-thi\run-ui.bat
# macOS/Linux:
chmod +x thuc-thi/run-ui.sh && thuc-thi/run-ui.shSửa source/src/main/resources/application.properties:
db.path=database/smartbrew.dbstrategy.student.percent=0.10strategy.happyhour.start=14:00,strategy.happyhour.end=17:00,strategy.happyhour.percent=0.20voucher.codes=VOUCHER10,TEACHER20, kèm.percent&.cap
Ghi đè nhanh khi test:
mvn -Dsmartbrew.db.path=:memory: test
Định nghĩa class implement com.designpatterns.smartbrew.plugin.PricingStrategyProvider và xuất bản trong
META-INF/services/com.designpatterns.smartbrew.plugin.PricingStrategyProvider. Thả .jar vào classpath là StrategyFactory tự load.
- Mặc định UI dùng định dạng tiền tệ Việt Nam (₫). Bạn có thể tùy biến trong
Formats. - Lần chạy đầu sẽ tạo DB file; hoặc chạy
sqlite3 database/smartbrew.db < database/schema.sqlđể tạo thủ công. - Nếu cần JavaFX UI hoặc jpackage (.exe/.dmg), thêm module tương ứng vào
pom.xml(V1.2/V1.3).