---
# System prepended metadata

title: Untitled

---

## Câu 1
### Flow Chart
* Euclide GCD
```mermaid
  graph TD
  start([Start]) --> input[/Input A, B/] 
  input --> temp1(( ))
  temp1 --> IfBis0{ B = 0 ? }
  IfBis0 -->|no| IfAgrterB{ A > B ? }
  IfAgrterB -->|no| subB[B <- B - A]
  subB --> temp2(( ))
  IfAgrterB -->|yes| subA[A <- A - B]
  subA --> temp2
  temp2 --> temp1
  IfBis0 -->|yes| print[/Print A/]
  print --> End([End])
```
* Quadratic Equation
```mermaid
  graph TD
  start([Start]) --> Input[/Input a, b, c/]
  Input --> IfaIs0{ a = 0 ? }
  IfaIs0 -->|no| D[D <- b*b - 4*a*c]
  D --> IfDsml0{ D < 0? }
  IfDsml0 -->|no| IfDis0{ D = 0 ?}
  IfDis0 -->|no| 2root[x1, x2]
  2root --> End([End])
  IfaIs0 -->|yes| FDE[First Degree Equation]
  IfDsml0 -->|yes| noRoot[No Root]
  IfDis0 --> |yes| 1root[x]
  FDE --> End
  noRoot --> End
  1root --> End
```
$$
x1 = {-b + \sqrt{b^2-4ac} \over 2a}
$$
$$
x2 = {-b - \sqrt{b^2-4ac} \over 2a}
$$
$$
x = {-b / 2a}
$$

## Câu 2
### Class Diagram
```mermaid
classDiagram
	class Address{
    street: String
    city: String
    state: String
    zipcode: Int
    }
  Address: enterStreet()
  Address: enterCity()
  Address: enterState()
  Address: enterZipCode()
  
    class Product{
    productID: Int
    productName: String
    productPrice: Float
  }
  Product: getPrice()
  Product: setPrice()
  
  class Product{
    productID: Int
    productName: String
    productPrice: Float
  }

  Product: getPrice()
  Product: setPrice()

  class PurchaseDetail{
    custID: Int
    quantity: Int
    purchaseDate: Date
    productID: Int
  }
  PurchaseDetail: caculateTotalArm()
  PurchaseDetail: generatePurchaseList()
  
  class Customer{
    custName: String
    custID: Int
    custPhnum: Int
  }
  Customer: purchaseIte()
  Customer: requestBill()
  Customer: enterCustDetail()
  
  class PremiumCustomer{
    premiumDiscount: Int
  }
  PremiumCustomer: enterCusDetail()

  class RegularCustomer{
    RegularDiscount: Int
  }
  RegularCustomer: enterCusDetail()
  
  class Discount{
    discountType
    discountValue
  }
  Discount: SelectDiscount()
  
  class Bill{
    payableAmt
  }
  Bill: caculatePayableAmt()
  Bill: generateBill()
  
  class PaymentCounter{
  }
  PaymentCounter: caculatePayableAmt()
  PaymentCounter: generateBill()
  
  Address "1" --* "1" Customer: has
  Product "* Purchases" -- "1 Is Sold To" Customer
  PurchaseDetail -- Product
  PurchaseDetail -- Customer
  PremiumCustomer --|> Customer
  RegularCustomer --|> Customer
  Discount ..> PurchaseDetail
  Bill ..> PurchaseDetail
  Bill ..> Discount
  Bill --o Customer: Belongs to
  Bill ..|> PaymentCounter: Accepts
```
## Câu 3
### Sequence Diagram

```mermaid
sequenceDiagram
participant C as : Customer
participant SP as : Search Pages
participant SRP as : Search Results Page
participant Ca as : Catalog
participant SR as : Search Results

 C ->> SP: 1: OnSearch(author)
 loop
 SP ->> SP: 1.1: validateSearchCriteria()
 end
 alt author entered
 SP ->> Ca: 1.2: searchByAuthor(author)
 Ca ->> SR: 1.2.1: create()
 SR ->> SRP: 1.2.1.1: display()
 else author not entered
 loop 
  SP ->> SP: 1.3: displayErrorMessage()
 end
 end

```

## Câu 4
### State Chart Diagram
```mermaid
stateDiagram
 s4: Idle
 [*] --> s4
 s3: PrintReceipt
 s1: AccountActions
 s2: DispenseMoney
 s1--> s3
 s1 --> s2
 s2 --> s3
 state TransactionComplete
 s2 --> TransactionComplete
 s3 --> TransactionComplete
 TransactionComplete --> s4
 s4 --> VerifyAccount
 state CardValid
 state VerifyAccount{
     state VerifyCard{
         cardSubmitted 
         readCard
         returnCard
      }
      VerifyCard --> CardValid
      s4: Idle
      CardValid --> s4: [else]
      s5: CardValid
      CardValid --> s5: [cardValid]
      state VerifyPin{
         pinSubmitted 
         checkPin
         returnCard
      }
     s5-->VerifyPin
     s6: PinCorrect
     s7:PinIncorrect
     state PINCorrect
     VerifyPin -->  PINCorrect
     PINCorrect--> s6: [PINValid]
     PINCorrect --> s7: [else]
     s7 --> VerifyPin: [tries < maxTries]/tries++
 }
```
Notes: 2 states "Idle" are one


 
