---
# System prepended metadata

title: 'Seminar #1 - Mermaid'

---

Seminar #1 - Mermaid
===

## :memo: Group Members

|  MSSV   | Full name         |
| ------- | ----------------- |
| 1712785 | Trần Quang Thiện  |
| 1712799 | Lê Trí Thông      |
| 1712813 | Nguyễn Thanh Tiến |

---
## :one: Flow Chart
- Euclide GCD
```mermaid
  graph TD
  A[Input A,B] --> B{ B = 0}
  B-- NO --> C{ A > B}
  C -- YES --> H[A <- A - B]
  H --> B
  C-- NO --> D[ B <- B -A]
  D --> B
  B -- YES --> F[Print A]
  F --> G[END]
```
```=
graph TD
  A[Input A,B] --> B{ B = 0}
  B-- NO --> C{ A > B}
  C -- YES --> H[A <- A - B]
  H --> B
  C-- NO --> D[ B <- B -A]
  D --> B
  B -- YES --> F[Print A]
  F --> G[END]
```
- Quadratic Equation
```mermaid
graph TD
	A("Quadratic Equation ax² + bx + c = 0") --> B{a = 0}	
	B -->|False| E["Δ = b² - 4ac"]
	B -->|True| D{"b = 0"}
	E --> F{"Δ ≥ 0"}
	F --> |True| G{"Δ > 0"}
	F --> |False| H["x ∈ ∅"] --> Over
	
	G --> |True| I["x₁ = (-b + sqrt(Δ)) / 2a, x₂ = (-b + sqrt(Δ)) / 2a"] --> Over
	G --> |False|J["x = -b / 2a"] --> Over
	
	D --> |False| L["x = -c / b"] --> Over
	D --> |True| K{"c = 0"}
	K --> |False| M["x ∈ ∅"] --> Over
	K --> |True| N["x ∈ R"] --> Over
	Over("End")
```
```=
graph TD
	A("Quadratic Equation ax² + bx + c = 0") --> B{a = 0}	
	B -->|False| E["Δ = b² - 4ac"]
	B -->|True| D{"b = 0"}
	E --> F{"Δ ≥ 0"}
	F --> |True| G{"Δ > 0"}
	F --> |False| H["x ∈ ∅"] --> Over
	
	G --> |True| I["x₁ = (-b + sqrt(Δ)) / 2a, x₂ = (-b + sqrt(Δ)) / 2a"] --> Over
	G --> |False|J["x = -b / 2a"] --> Over
	
	D --> |False| L["x = -c / b"] --> Over
	D --> |True| K{"c = 0"}
	K --> |False| M["x ∈ ∅"] --> Over
	K --> |True| N["x ∈ R"] --> Over
	Over("End")
```
---
## :two: Class Diagram
[![](https://mermaid.ink/img/eyJjb2RlIjoiY2xhc3NEaWFncmFtXG4gIGNsYXNzIEFkZHJlc3N7XG4gICAgc3RyZWV0OiBTdHJpbmdcbiAgICBjaXR5OiBTdHJpbmdcbiAgICB6aXBjb2RlOiBJbnRcbiAgICBlbnRlclN0cmVldCgpXG4gICAgZW50ZXJDaXR5KClcbiAgICBlbnRlclN0YXRlKClcbiAgICBlbnRlclppcGNvZGUoKVxuICB9XG4gIGNsYXNzIEN1c3RvbWVye1xuICAgIGN1c3ROYW1lOiBTdHJpbmdcbiAgICBjdXN0SUQ6IEludFxuICAgIGN1c3RQaE51bTogSW50XG4gICAgcHVyY2hhc2VJdGVtKClcbiAgICByZXF1ZXN0QmlsbCgpXG4gICAgZW50ZXJDdXN0RGV0YWlsKClcbiAgfVxuICBjbGFzcyBQcm9kdWN0e1xuICAgIHByb2R1Y3RJRDogSW50XG4gICAgcHJvZHVjdE5hbWU6IFN0cmluZ1xuICAgIHByb2R1Y3RQcmljZTogRmxvYXRcbiAgICBnZXRQcmljZSgpXG4gICAgc2V0UHJpY2UoKSBcbiAgfVxuICBjbGFzcyBQdXJjaGFzZURldGFpbHtcbiAgICBjdXN0SUQ6IEludFxuICAgIHF1YW50aXR5OiBJbnRcbiAgICBwdXJjaGFzZURhdGU6IERhdGVcbiAgICBwcm9kdWN0SUQ6IEludFxuICAgIGNhbGN1bGF0ZVRvdGFsQW10KClcbiAgICBnZW5lcmF0ZVB1cmNoYXNlTGlzdCgpXG4gIH1cbiAgY2xhc3MgRGlzY291bnR7XG4gICAgZGlzY291bnRUeXBlXG4gICAgZGlzY291bnRWYWx1ZVxuICAgIFNlbGVjdERpc2NvdW50KClcbiAgfVxuICBjbGFzcyBCaWxse1xuICAgIHBheWFibGVBbXRcbiAgICBjYWxjdWxhdGVQYXlhYmxlQW10KClcbiAgICBnZW5lc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XN0RGV0YWlsKClcbiAgfVxuICBjbGFzcyBQYXltZW50Q291bnRlciB7XG4gICAgPDxpbnRlcmZhY2U-PlxuICAgIGNhbGN1bGF0ZVBheWFibGVBbXQoKVxuICAgIGdlbmVyYXRlQmlsbCgpXG4gIH1cbiAgQWRkcmVzcyBcIjFcIiAtLSogXCIxXCIgQ3VzdG9tZXI6IEhhc1xuICBDdXN0b21lciBcIjEgSVMgU09MRCBUT1wiIC0tIFwiKiBQdXJjaGFzZXNcIlByb2R1Y3RcbiAgQ3VzdG9tZXIgLS0gUHVyY2hhc2VEZXRhaWxcbiAgUHJlbWl1bUN1c3RvbWVyIC0tfD4gQ3VzdG9tZXJcbiAgUmVndWxhckN1c3RvbWVyIC0tfD4gQ3VzdG9tZXJcbiAgQmlsbCAtLW8gQ3VzdG9tZXI6IEJlbG9uZ3MgdG9cbiAgQmlsbCAuLnw-IFBheW1lbnRDb3VudGVyOiBBY2NlcHRzXG4gIEJpbGwgLi4-IFB1cmNoYXNlRGV0YWlsXG4gIEJpbGwgLi4-IERpc2NvdW50XG4gIERpc2NvdW50IC4uPiBQdXJjaGFzZURldGFpbFxuICBQdXJjaGFzZURldGFpbCAtLSBQcm9kdWN0IiwibWVybWFpZCI6eyJ0aGVtZSI6ImRlZmF1bHQifSwidXBkYXRlRWRpdG9yIjpmYWxzZX0)
```=
classDiagram
  class Address{
    street: String
    city: String
    zipcode: Int
    enterStreet()
    enterCity()
    enterState()
    enterZipcode()
  }
  class Customer{
    custName: String
    custID: Int
    custPhNum: Int
    purchaseItem()
    requestBill()
    enterCustDetail()
  }
  class Product{
    productID: Int
    productName: String
    productPrice: Float
    getPrice()
    setPrice() 
  }
  class PurchaseDetail{
    custID: Int
    quantity: Int
    purchaseDate: Date
    productID: Int
    calculateTotalAmt()
    generatePurchaseList()
  }
  class Discount{
    discountType
    discountValue
    SelectDiscount()
  }
  class Bill{
    payableAmt
    calculatePayableAmt()
    generateBill()
  }
  class PremiumCustomer{
    premiumDiscount: Int
    enterCustDetail()
  }
  class RegularCustomer{
    regularDiscount: Int
    enterCustDetail()
  }
  class PaymentCounter {
    <<interface>>
    calculatePayableAmt()
    generateBill()
  }
  Address "1" --* "1" Customer: Has
  Customer "1 IS SOLD TO" -- "* Purchases"Product
  Customer -- PurchaseDetail
  PremiumCustomer --|> Customer
  RegularCustomer --|> Customer
  Bill --o Customer: Belongs to
  Bill ..|> PaymentCounter: Accepts
  Bill ..> PurchaseDetail
  Bill ..> Discount
  Discount ..> PurchaseDetail
  PurchaseDetail -- Product
```
---
## :three: Sequence Diagram
```mermaid
sequenceDiagram
    activate Customer
    participant Customer as Customer
    participant A as : Search Page
    participant B as : Search Result Page
    participant C as : Catalog
    participant D as : Search Result

    Customer->>+A: 1: onSearch(author)
    A->>A: 1.1: validateSearchCriteria()

    alt author entered
      A->>C: 1.2: searchByAuthor(author)
      activate C
      C->>+D: 1.2.1: create()
      D->>-B: 1.2.1.1: display()
      activate B
      deactivate B
    else author not entered
      deactivate C
      A->>-A: displayErrorMessage()
    end
    deactivate Customer
```
```=
sequenceDiagram
    activate Customer
    participant Customer as Customer
    participant A as : Search Page
    participant B as : Search Result Page
    participant C as : Catalog
    participant D as : Search Result

    Customer->>+A: 1: onSearch(author)
    A->>A: 1.1: validateSearchCriteria()

    alt author entered
      A->>C: 1.2: searchByAuthor(author)
      activate C
      C->>+D: 1.2.1: create()
      D->>-B: 1.2.1.1: display()
      activate B
      deactivate B
    else author not entered
      deactivate C
      A->>-A: displayErrorMessage()
    end
    deactivate Customer
```
---
## :four: State Chart Diagram
[![](https://mermaid.ink/img/eyJjb2RlIjoic3RhdGVEaWFncmFtIFxuXHRbKl0gLS0-IElkbGVcblx0c3RhdGUgSWRsZSB7fVxuICBJZGxlIC0tPiBWZXJpZnlBY2NvdW50XG4gIHN0YXRlIFZlcmlmeUFjY291bnQge1xuICAgIHN0YXRlIFZlcmlmeUNhcmQge1xuICAgICAgY2FyZFN1Ym1pdHRlZFxuICAgICAgcmVhZENhcmR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Y2NvdW50QWN0aW9ucyB7fVxuICBzdGF0ZSBEaXNwZW5zZU1vbmV5IHt9XG4gIHN0YXRlIFByaW50UmVjZWlwdCB7fVxuICBBY2NvdW50QWN0aW9ucyAtLT4gRGlzcGVuc2VNb25leVxuICBBY2NvdW50QWN0aW9ucyAtLT4gUHJpbnRSZWNlaXB0XG4gIERpc3BlbnNlTW9uZXkgLS0-IFByaW50UmVjZWlwdFxuICBEaXNwZW5zZU1vbmV5IC0tPiBbKl0gXG4gIFByaW50UmVjZWlwdCAtLT4gWypdICIsIm1lcm1haWQiOnsidGhlbWUiOiJkZWZhdWx0In0sInVwZGF0ZUVkaXRvciI6ZmFsc2V9)
```=
stateDiagram 
	[*] --> Idle
	state Idle {}
  Idle --> VerifyAccount
  state VerifyAccount {
    state VerifyCard {
      cardSubmitted
      readCard
      returnCard
    } 
    state CardValid {}

    VerifyCard --> isCardValid
    isCardValid --> CardValid: true
    isCardValid --> Idle: false
    state Idle {}
    Idle --> VerifyCard

    CardValid --> VerifyPin
    state VerifyPin {
      pinSubmitted
      checkPin
      returnCard
    }
    VerifyPin --> isPinCorrect
    isPinCorrect --> PinCorrect : [pinValid]
    isPinCorrect --> PinIncorrect : [else]
      
    state PinCorrect {}
    state PinIncorrect {}

    PinIncorrect --> VerifyPin: [tries < maxTries] / tries++  
  }
  state AccountActions {}
  state DispenseMoney {}
  state PrintReceipt {}
  AccountActions --> DispenseMoney
  AccountActions --> PrintReceipt
  DispenseMoney --> PrintReceipt
  DispenseMoney --> [*] 
  PrintReceipt --> [*] 
```