11.28

```mermaid
classDiagram
    class BankAccount {
        - double balance
        - AccountState state
        + deposit(double)
        + withdraw(double)
        + setBalance(double)
        + setState(AccountState)
    }

    class AccountState {
        <<interface>>
        + deposit(double)
        + withdraw(double)
    }

    class NormalState {
        - BankAccount account
        + deposit(double)
        + withdraw(double)
    }

    class OverdraftState {
        - BankAccount account
        + deposit(double)
        + withdraw(double)
    }

    BankAccount --> AccountState
    AccountState <|.. NormalState
    AccountState <|.. OverdraftState

```
posted @ 2024-11-28 21:02  徐星凯  阅读(5)  评论(0)    收藏  举报