菜鸟的博客

纵有疾风起,人生不言弃。

导航

软件设计-Tutroial22

```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 on 2024-11-26 15:35  hhmzd233  阅读(6)  评论(0编辑  收藏  举报