```plantuml
@startuml
class Subject <<abstract>>{
+ ~Subject()
+ attach(obersever: Observer*): void
+ detach(observer: Observer*): void
+ notify(): void
}

class Observer <<interface>>{
+ {abstract} update(): void
+ ~Observer()
}

class SystemBattery{
+ setBatteryLevel(data: int): void
+ getData(): int
- BatteryLevel: int
}

class BatteryApp{
+ BatteryApp(subject: SystemBattery&, name: string)
+ update(): void
- name: string
}

class BatteryLogger{
+ BatteryLogger(subject: SystemBattery&, name: string)
+ update(): void
- name: string
}

Subject <|-- SystemBattery 
Observer <|-- BatteryApp 
Observer <|-- BatteryLogger

SystemBattery "1" *- "*" BatteryApp: - subject: SystemBattery&
SystemBattery "1" *- "*" BatteryLogger: - subject: SystemBattery&
Subject "*" -o "*" Observer: - observers: list<Observer*>


@enduml
```


```mermaid
sequenceDiagram
    actor human
    activate human
    create participant Main
    human -)+ Main: <<create>>

    Note over Main: create Observers and Subject
    create participant SystemBattery as systemBattery: Subject
    Main ->>+ SystemBattery: <<create>>
    SystemBattery --)- Main: return

    create participant Observer as batteryApp: Observer
    Main ->>+ Observer: <<create>>(SystemBattery* = *systemBattery, name = "BatteryApp")
    Observer->>+ SystemBattery: attach(this)
    SystemBattery ->> SystemBattery: observers.push_back(batteryApp)
    SystemBattery --)- Observer: return
    Observer --)- Main: return

    create participant Logger as batteryLogger: Observer
    Main ->>+ Logger: <<create>>(SystemBattery* = *systemBattery, name = "BatteryLogger")
    Logger->>+ SystemBattery: attach(this)
    SystemBattery ->> SystemBattery: observers.push_back(batteryLogger)
    SystemBattery --)- Logger: return
    Logger --)- Main: return

    Note over Main: Set BatteryLevel to 87
    Main ->>+ SystemBattery: setBatteryLevel(data = 87)
    activate SystemBattery
    SystemBattery -->> SystemBattery: BatteryLevel = data
    SystemBattery --) human: "New value 87

%% Loop for each observer
    note over SystemBattery: update each Observer
    SystemBattery ->>+ SystemBattery: notify()
    SystemBattery ->>+ Observer: update()
    Observer ->>+ SystemBattery: getData()
    SystemBattery --)- Observer: return BatteryLevel
    Observer -->> Observer: newValue = BatteryLevel
    Observer --) human: "This is batteryApp! Received value 87"
    Observer --)- SystemBattery: return

    SystemBattery ->>+ Logger: update()
    Logger ->>+ SystemBattery: getData()
    SystemBattery --)- Logger: return BatteryLevel
    Logger -->> Logger: newValue = BatteryLevel
    Logger --) human: "TThis is batteryLogger! Received value 87! Will proceed to log value into file..."
    Logger -->> Logger: log data into file
    Logger --)- SystemBattery: return
%% end loop
    deactivate SystemBattery
    SystemBattery --)- Main: return

    Note over Main: delete created Objects
    Main --x Observer: <<delete>>
    activate Observer
    Observer ->>+ SystemBattery: detach(this)
    SystemBattery ->> SystemBattery: overservers.remove(batteryApp)
    deactivate Observer
    destroy Observer
    SystemBattery --)- Observer: return

    Main --x Logger: <<delete>>
    activate Logger
    Logger ->>+ SystemBattery: detach(this)
    SystemBattery ->> SystemBattery: overservers.remove(batteryLogger)
    deactivate Logger
    destroy Logger
    SystemBattery --)- Logger: return

    destroy SystemBattery
    Main --x SystemBattery: <<delete>>

    Main --)- human: return

    destroy Main
    human --x Main: <<destroy>>
    deactivate human
```