---
# System prepended metadata

title: TKPM01 - Seminar01 - Mermaid - Bài làm

---

# TKPM01 - Seminar01 - Mermaid - Bài làm
## 1712798 - 1712803

### 1. Flowchart
1. Euclide GCD
```mermaid
graph TB
	s((start))
	nhap[/Nhập A,B/]
	xuat[/Xuất A/]		
	ktB{B=0}
	ktAB{A>B}
	subA(A=A-B)
	subB(B=B-A)
	e((stop))

	s-->nhap
	nhap-->ktB
	ktB--false-->ktAB
	ktB--true-->xuat
	xuat-->e
	ktAB--false-->subB
	ktAB--true-->subA
	subB-->ktB
	subA-->ktB
```
2. Quadratic Equation
```mermaid
graph TD
	s((start))
	nhap[/Nhập a,b,c/]
	xuat1[/phương trình vô nghiệm/]	
	xuat2[/phương trình có 1 nghiệm x /]	
	xuat3[/phương trình có 2 nghiệm x1, x2/]	
	ktA{a=0}
	ktDelta{delta>=0}
	delta(delta=b*b-4ac)
	tinhx("x=-c/b")
	tinhx12("x1=(-b-sqrt(delta))/2a<br>x2=(-b+sqrt(delta))/2a")
	e((stop))

	s-->nhap
	nhap-->ktA
	ktA--false-->delta
	ktA--true-->tinhx
	tinhx-->xuat2
	xuat2-->e
	delta-->ktDelta
	ktDelta--false-->xuat1
	xuat1-->e
	ktDelta--true-->tinhx12
	tinhx12-->xuat3
	xuat3-->e
```
### 2. 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{
	premiumDiscount: 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()
		generatePurchaseList()
	}

	class Discount{
		discountType
		discountValue
		SelectDiscount()
	}

	class Bill{
		payableAmt
		calculatePayableAmt()
		generateBill()
	}

	class PaymentCounter{
        interface
		calculatePayableAmt()
		generateBill()
	}

	Address "1" --* "1" Customer : Has
	Customer "1" -- "*" Product
	Customer -- PurchaseDetail
	Product -- PurchaseDetail
	PremiumCustomer --|> Customer
	RegularCustomer --|> Customer
	Bill --o Customer : Belongs to
	Bill ..|> PaymentCounter : Accepts
	Bill ..> PurchaseDetail
	Bill ..> Discount
	Discount ..> PurchaseDetail
```
### 3. Sequence Diagram
```mermaid
    sequenceDiagram
        participant actor as :Customer
        participant action1 as :Search Page
        participant action2 as :Search Results Page
        participant action3 as :Catalog
        participant action4 as :Search Results

        activate actor
        actor->>+action1: 1:onSearch(author)
        action1->>action1: 1.1:validateSearchCriteria()
        alt [author entered]
            action1->>+action3: 1.2:searchByAuthor(author)
            action3->>+action4: 1.2.1:create()
            action4->>+action2: 1.2.1.1:display()
            deactivate action2
            deactivate action4
        else [author not entered]
            deactivate action3
            action1->>action1: 1.3:displayErrorMessage()
            deactivate action1
        end
        deactivate actor
```
### 4. State Diagram
```mermaid
stateDiagram
	idle: Idle

	printreceipt: PrintReceipt
	dispensemoney: DispenseMoney
	accountactions: AccountActions

	state VerifyAccount{
		VerifyCard --> cardvalid : [cardValid]
        cardvalid --> VerifyPin
        VerifyPin --> PinCorrect : [PINValid]
        VerifyPin --> PinIncorrect : [else]
        PinIncorrect --> VerifyPin : [tries"<"maxTries]/tries++

		state VerifyCard{
		cardSubmitted
		readCard
		returnCard
	}
	cardvalid: CardValid
	state VerifyPin{
		pinSubmitted
		checkPin
		returnCard
	}
	}

	%%[*] as start
	[*] --> idle
	idle -->VerifyAccount
	VerifyAccount-->idle : [cardInvalid]
	TransactionComplete --> idle
	
	accountactions --> dispensemoney
	accountactions --> printreceipt
	dispensemoney --> printreceipt
	printreceipt --> TransactionComplete
	dispensemoney --> TransactionComplete

```