---
# System prepended metadata

title: TKPM-Mermaid

---

# TKPM-Mermaid
# Bai 1
[](https://unpkg.com/mermaid@8.5.0/dist/)
**Flow Chart**
* Euclide GCD
``` mermaid
graph TD
  A((Start)) --> B([Input A, B])
  B --> C(( ))
  C --> D{B=0}
  D --> |No|E{A>B}
  K --> N
  D --> L[Print A]
  L --> M((End))
  E --> |"No (< or =)"|F[B<-B-A]
  F --> G[GOTO 2]
  G --> N(( ))
  N --> C
  E --> |Yes|H[A<-A-B]
  H --> K[GOTO 2]
  
```
* Quadratic Equation
``` mermaid
graph TD
  A((Start)) --> B([Read A, B, C])
  B --> C[D = b*b - 4ac]
  C --> D{D >= 0?}
  D --> |Yes| E["X1 = (-b + sqrt d)/2a"]
  E --> F["X2 = (-b - sqrt d)/2a"]
  F --> G([Print X1, X2])
  D --> |No| I([Print No Real Solution])
  G --> H((Stop))
  I --> H
			
```

# Bai 2
**Class Diagram**
![](https://i.imgur.com/vuZNZux.png)

> Code Here
``` mermaid
classDiagram
class Customer {
    String custName
    Int custID
    Int CustPhnum
    purchaseItem()
    requestBill()
    enterCustDetail()
}

class PremiumCustomer {
    Int premiumDiscount
    enterCustDetail()
}

class RegularCustomer {
    Int regularDiscount
    enterCustDetail()
}

class Bill {
    payableAmt
    calculatePayableAmt()
    generateBill()
}

class Discount {
    discountType
    discountValue
    SelectDiscount()
}

class PurchaseDetail {
    Int custID
    Int quantity
    Date purchaseDate
    Int productID
    calculateTotalAmt()
    generatePurchaseList()
}

class Product {
    Int productID
    String productName
    Float productPrice
    getPrice()
    setPrice()
}

class Address{
    String street
    String city
    String state
    Int zipcode
    enterStreet()
    enterCity()
    enterState()
    enterZipCode()
}

class PaymentCounter {
    <<interfaces>>
    calculatePayableAmt()
    generateBill()
}

Customer <|-- PremiumCustomer
Customer <|-- RegularCustomer
Customer "1" *-- "1" Address : Has
PaymentCounter <|.. Bill : Accepts
Customer o-- Bill : Belongs to
Discount <.. Bill
PurchaseDetail <.. Bill
PurchaseDetail <.. Discount
Customer -- PurchaseDetail
Product -- PurchaseDetail
Customer "Is Sold To 1" -- "Purchases *" Product
```

>Code chạy trên Mermaid Live Editor
![](https://i.imgur.com/NbPshAl.png)


# Bai 3
**Sequence Diagram**
![](https://cdn.visual-paradigm.com/guide/uml/what-is-sequence-diagram/16-sequence-diagram-for-use-case.png)

> Code Here

``` mermaid
sequenceDiagram
    participant Customer
    participant Search Page
    participant Search Results Page
    Customer->>Search Page: 1: onSearch(author) 
    
    
    activate Search Page
    Search Page->>Search Page: 1.1 validateSearchCretirial() 
     
    alt entered
        
        Search Page->>Catalog: 1.2: searchByAuthor(author)
        
        activate Catalog
        Catalog->>Search Results: 1.2.1: create()
        
        activate Search Results
        Search Results->>Search Results Page: 1.2.1.1: display()
        
        activate Search Results Page
        deactivate Search Results Page
        
        deactivate Search Results
        deactivate Catalog
    else author not entered
        Search Page->>Search Page: 1.3: displayErrorMessage()
    end
    deactivate Search Page
    

```
# Bai 4
**State Chart Diagram**
![](https://support.content.office.net/en-us/media/3ac1da3e-ab76-41a8-85ba-5e48752138db.png)

> Code Here

``` mermaid
stateDiagram
    state "PrintReceipt" as s1
    state "DispenseMoney" as s2
    state "AccountActions" as s3
    state "Idle" as s4
    
    
   
    
    s3 --> s2
    s3 --> s1
    s2 --> s1
    s2 --> [*] 
    s1 --> [*]
    [*] --> s4
    
    s4-->VerifyAccount
    VerifyAccount --> s4 : else
    state VerifyAccount {
        state "VerifyCard" as s5
        s5: cardSubmitted /
        s5: readCard /
        s5: returnCard /
        
        state "CardValid?" as s6_1
        state "CardValid" as s6_2
        
        s5 --> s6_1
        s6_1 --> s6_2 : [CardValid]
        
        s6_2 --> s7
        
        state "VerifyPin" as s7
        s7 : pinSubmitted /
        s7 : checkPin /
        s7 : returnCard /
        state "PinCorrect?" as s8
        state "PinIncorrect" as s9
        state "PinCorrect" as s10
        
        s7 --> s8
        s8 --> s10 : [PINValid]
        s8 --> s9 : [else]
        s9 --> s7 : [tries < maxTries] / tries++
        
        
        
    }
```   
