---
# System prepended metadata

title: Bài tập try hard HackMD

---

# Bài tập try hard HackMD
### Thành viên nhóm
1. Nguyễn Hoàng Phúc 1712673
2. Vũ Duy Quang 1712708
3. Vũ Phạm Đức Thắng 1712763
## Flow Chart
### Euclide
```mermaid
graph TD 
  A(Bắt đầu)
  B[/Nhập a,b/]
  C{a=b}
  D{a>b}
  E[b:=b-a]
  F[Ước chung lớn nhất:= a]
  G[a:=a-b]
  H((Kết thúc))
  A-->B-->C
  C--True-->F
  F-->H
  C--False-->D
  D--True-->G
  D--False-->E
  G-->C
  E-->C

```
### Quadratic Equation
```mermaid
graph TD 
    start(Bắt đầu) --> input[/Nhập a, b, c/]
    input --> compareA{a = 0}
    compareA --True--> compareB{b = 0}
    
    compareB --True--> compareC{c = 0}
    compareC --True--> kl1[PHương trình có vô số nghiệm]
    compareC --False--> kl2[Phương trình vô nghiệm]
    
    compareB --False--> x["Phương trình có nghiệm: x = -c/a"]
    
    
    compareA --False--> delta[delta = b^2 - 4ac]
    delta --> compareDelta1{delta < 0}
    compareDelta1 --False--> compareDelta2{delta = 0}
    compareDelta1 --True--> kl[Phương trình vô nghiệm]
    compareDelta2 --True--> result1[Phương trình có nghiệm kép<br>x = -b/2a]
    compareDelta2 --False--> result2["Phuong trình có hai nghiệm<br>x1 = (-b - sqrt(delta))/2a<br>x2 = (-b + sqrt(delta))/2a"]
    
    
    
```


## Class Diagram
```mermaid
classDiagram
  class Address {
    street: string
    city: string
    state: string
    zipcode: Int

    enterStreet()
    enterCity()
    enterState()
    enterZipcode()

  }

  class Customer {
    custName: string
    custID: Int
    custPhnum: Int

    purchaseItem()
    requestBill()
    enterCustDetail()

  }

  class PremiumCustomer {
    premiumDiscout: Int
    
    enterCustDetail()
  }

  class RegularCustomer { 
    regularDiscount: Int

    enterCustDetail()
  }
  
  class Product {
    productID: Int
    productName: string
    productPrice: Float

    getPrice()
    setPrice()
    
  }
  class PurchaseDetail { 
      custID: Int
      quantity: Int
      purchaseDate: Date
      productID: Int

      calculateTotalAmt()
      generatPurchaseList()
  }
  class Discount { 
    discoutType
    discoutValue

    SelectDiscount()
  }
  
  class Bill { 
    payAbleAmt

    calculatePayAbleAmt()
    generateBill()
    }
  

  Customer <|-- RegularCustomer
  Customer <|-- PremiumCustomer
  Address "1" --* "1" Customer: Has
  Product "*" -- "1" Customer: Is Sold To
  Product -- PurchaseDetail
  Customer o-- Bill: Belong to
  Customer -- PurchaseDetail
  PurchaseDetail <.. Discount
  PurchaseDetail <.. Bill
  Discount <.. Bill
  Bill ..|> PaymentCounter: Accepts
  
  class PaymentCounter {      
    calculatePayAbleAmt()
    generateBill()
  }
```
## Sequence Diagram
```mermaid
  sequenceDiagram
    participant _Customer
    participant _Search Page
    participant _Search Results Page
    participant _Catalog
    participant _Search Results
   
    activate _Customer
    _Customer ->>+ _Search Page: 1.onSearch(author)
    _Search Page ->> _Search Page: 1.1.validateSearchCriteria()
    
    alt author enntered
      _Search Page ->>+ _Catalog: 1.2.searchByAuthor(author)
      
      _Catalog ->>+ _Search Results: 1.2.1.create()
      _Search Results ->>+ _Search Results Page: 1.2.1.1.display()
      
      deactivate _Catalog
      deactivate _Search Results 
      deactivate _Search Results Page
    
    else author not entered
      _Search Page ->> _Search Page: 1.3.displayErrorMessage()  
    end  
    
    deactivate _Search Page
    deactivate _Customer
    
    
```

## State Diagram
```mermaid
stateDiagram 
    
    [*] --> Idle
    
    AccountAction --> DispenseMoney
    AccountAction --> PrintReceipt
    DispenseMoney --> PrintReceipt
    PrintReceipt --> [*]
    DispenseMoney --> [*] 
    
       
    
    Idle --> VerifyAccount
    state VerifyAccount {
    
        VerifyCard --> CardInvalid: Card not valid
        VerifyCard -->CardValid:CardValid
        
        CardValid --> VerifyPIN
        
        VerifyPIN --> PinCorrect
        
        VerifyPIN --> PinIncorrect
        PinIncorrect --> VerifyPIN
        
        
    }
    
    
    
    
    
```