---
# System prepended metadata

title: Câu 1

---

# Câu 1
## a. Tìm ước chung lớn nhất

```mermaid
graph TD
	A(Bắt đầu) --> B[/Nhập 2 số a, b/]
	B --> C{a=b}
    C -->|Đúng| D[/Hiển thị ước chung lớn nhất/]
	E -->|Đúng| F[a=a-b]
    C -->|Sai| E{a>b}
    E -->|Sai| G[b=b-a]
	F --> C
	G --> C
	D --> H(Kết thúc)
```


## b. Giải và biện luận phương trình bậc 2
```mermaid
graph TD
	A(Bắt đầu) --> B[/Nhập 3 số a, b, c/]
	B --> C{a=0}
	C --> |Sai| D[delta = b^2 - 4*a*c]
	D --> E{delta=0}
	E --> |Đúng| F["x1=-b/(2*a)"]
	F --> P[/Phương trình có nghiệm kép, x/]
	E --> |Sai| H{delta > 0}
	H --> |Đúng| K["x1=(delta^(1/2)-b)/(2*a*c), x2=(-delta^(1/2)-b)/(2*a*c)"]
	K --> G[/Phương trình có 2 nghiệm phân biệt, x1,x2/]
	H --> |Sai| L[/Phương trình vô nghiệm/]
	G --> T(Kết thúc)
	L --> T
	P --> T

	C --> |Đúng| U{b=0}
	U --> |Đúng| V{c=0}
	V --> |Sai| L
	U --> |Sai| N[x=-c/b]
	N --> M[/Phương trình có 1 nghiệm duy nhất, x/]
	V --> |Đúng| I[/Phương trình có vô số nghiệm/]
	
	M --> T
	I --> T
```

# Câu 2
```mermaid
classDiagram
    PremiumCustomer --|> Customer
    RegularCustomer --|> Customer
    
    PurchaseDetail -- Product
    PurchaseDetail -- Customer
    
    Bill ..|> PaymentCounter : Accepts
    Bill ..> Discount
    Bill ..> PurchaseDetail
    Bill --o Customer : Belongs to
    
    Discount ..> PurchaseDetail
    
    Customer "1" -- "*" Product : Is Sold To, Purchases
    
    Address "1" --* "1" Customer : Has
    
	class Customer{
        custName: String
        custID: Int
        custPhnum: Int
        purchaseItem()
        requestBill()
        enterCustDetail()
	}

	class PremiumCustomer{
        premiumDiscount: Int
        enterCustDetail()
	}

	class RegularCustomer{
        regularDiscount: Int
        enterCustDetail()
	}

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

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

	class PurchaseDetail{
        custID: Int
        quantity: Int
        purchaseDate: Date
        productID: Int
        caculateTotalAmt()
        generatePurchaseList()
	}
	class Discount{
        discountType
        discountValue
        SelectDiscount()
	}

	class Bill{
        payableAmt
        caculatePayableAmt()
        generateBill()
	}
        
   class PaymentCounter{
       <<>>
        caculatePayableAmt()
        generateBill()
    }
    
```

## Chú thích:
**Nguyên mẫu của class PaymentCounter**
```
class PaymentCounter{
       <<interface>>
        caculatePayableAmt()
        generateBill()
}
```
`Em không hiểu tại sao khi em chèn thêm text vào trong cặp dấu "<<>>" thì nó không hiển thị được.`
[Class Diagram em vẽ trong Mermaid live editor](https://mermaid-js.github.io/mermaid-live-editor/#/edit/eyJjb2RlIjoiY2xhc3NEaWFncmFtXG4gICAgUHJlbWl1bUN1c3RvbWVyIC0tfD4gQ3VzdG9tZXJcbiAgICBSZWd1bGFyQ3VzdG9tZXIgLS18PiBDdXN0b21lclxuICAgIFxuICAgIFB1cmNoYXNlRGV0YWlsIC0tIFByb2R1Y3RcbiAgICBQdXJjaGFzZURldGFpbCAtLSBDdXN0b21lclxuICAgIFxuICAgIEJpbGwgLi58PiBQYXltZW50Q291bnRlciA6IEFjY2VwdHNcbiAgICBCaWxsIC4uPiBEaXNjb3VudFxuICAgIEJpbGwgLi4-IFB1cmNoYXNlRGV0YWlsXG4gICAgQmlsbCAtLW8gQ3VzdG9tZXIgOiBCZWxvbmdzIHRvXG4gICAgXG4gICAgRGlzY291bnQgLi4-IFB1cmNoYXNlRGV0YWlsXG4gICAgXG4gICAgQ3VzdG9tZXIgXCIxXCIgLS0gXCIqXCIgUHJvZHVjdCA6IElzIFNvbGQgVG8sIFB1cmNoYXNlc1xuICAgIFxuICAgIEFkZHJlc3MgXCIxXCIgLS0qIFwiMVw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W50XG4gICAgICAgIGNhY3VsYXRlVG90YWxBbXQoKVxuICAgICAgICBnZW5lcmF0ZVB1cmNoYXNlTGlzdCgpXG5cdH1cblx0Y2xhc3MgRGlzY291bnR7XG4gICAgICAgIGRpc2NvdW50VHlwZVxuICAgICAgICBkaXNjb3VudFZhbHVlXG4gICAgICAgIFNlbGVjdERpc2NvdW50KClcblx0fVxuXG5cdGNsYXNzIEJpbGx7XG4gICAgICAgIHBheWFibGVBbXRcbiAgICAgICAgY2FjdWxhdGVQYXlhYmxlQW10KClcbiAgICAgICAgZ2VuZXJhdGVCaWxsKClcblx0fVxuICAgICAgICBcbiAgIGNsYXNzIFBheW1lbnRDb3VudGVye1xuICAgICAgIDw8aW50ZXJmYWNlPj5cbiAgICAgICAgY2FjdWxhdGVQYXlhYmxlQW10KClcbiAgICAgICAgZ2VuZXJhdGVCaWxsKClcbiAgICB9XG4gICIsIm1lcm1haWQiOnsidGhlbWUiOiJkZWZhdWx0In19)

# Câu 3
```mermaid
sequenceDiagram
	participant Customer
	participant Search Page
	participant Search Results Page
	participant Catalog
	participant Search Results
	activate Customer
	Note left of Customer: The Customer specifies an author <br/> on the Search Page and then <br/>presses the Search button.
	Customer ->>+ Search Page: 1:onsearch(author) 
	Note left of Customer: The system validates the <br/> Customer's search criterial.
	Search Page ->> Search Page: 1.1:validateSearchCriteria()
	alt author entered
	Note left of Customer:	If author is entered,  the System <br/>searches the Catalog for books <br/>assoicated with the specified author.
		Search Page ->> Catalog: 1.2:searchByAuthor(author)
		activate Catalog
		Catalog ->> Search Results: 1.2.1:create()
		activate Search Results
		Note left of Customer: When the search is complete, the <br/>system displays the search results on <br/>the Search Results Page.
		Search Results ->> Search Results Page: 1.2.1.1:display()
		deactivate Search Results
		activate Search Results Page
		deactivate Search Results Page
	else author not entered
		deactivate Catalog
		Note left of Customer: If the Customer did not enter the <br/>name of an author before pressing <br/>the Search button, the System displays <br/>an error message.
		Search Page ->>- Search Page: 1.3:displayErrorMessage()
	end
	deactivate Customer
```


# Câu 4
**ATM State Machine Diagram**

```mermaid
stateDiagram

	Idl: Idle

	state VerifyAccount{	
		VerC: VerifyCard

		CV: CardValid

		VP: VerifyPin

		PIC: PinIncorrect

		PC: PinCorrect

		CV --> VP
		VerC --> CardValid

		CardValid --> CV : [cardValid]

		VP --> PinCorrect

		PinCorrect --> PIC : [else]
		PinCorrect --> PC: [PINValid]
		PIC --> VP: [tries < maxTries]/tries++

		VP: pinSubmitted /
		VP: checkPin /
		VP: returnCard /

		
		VerC: cardSubmitted /
		VerC: readCard /
		VerC: returnCard /

	}
		

	PR: PrintReceipt
	DM: DispenseMoney
	AAc: AccountActions
	DM --> PR
	AAc --> DM
	AAc --> PR
	
	DM --> TransactionComplete
	PR --> TransactionComplete

	[*] --> Idl
	Idl --> VerifyAccount


	TransactionComplete --> Idl


	
	

	
	
					
```