Skip to content

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SmartBrew – Order App (Java, Maven)

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

Cấu trúc

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

Build & Run

# 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.sh

Config

Sửa source/src/main/resources/application.properties:

  • db.path=database/smartbrew.db
  • strategy.student.percent=0.10
  • strategy.happyhour.start=14:00, strategy.happyhour.end=17:00, strategy.happyhour.percent=0.20
  • voucher.codes=VOUCHER10,TEACHER20, kèm .percent & .cap

Ghi đè nhanh khi test:

mvn -Dsmartbrew.db.path=:memory: test

Plugin (SPI)

Đị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.

Ghi chú

  • 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).

About

Smart coffee monitoring and automation experiments with product-focused IoT thinking.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages