Skip to content
Snippets Groups Projects
ElectronicAppliances.txt 896 B
Newer Older
class ElectronicApplicance {
    boolean switch;
    double timeLimit;
    int sound;
    abstract void turnOn();
    abstract void turnOff();
    abstract boolean isTurnedOn();
}

class Television implements ElectronicApplicance{
    boolean switch;
    double timeLimit;
    String content;
    Television() {
        send packet to TV requesting its state
        receive packet for switch, timeLimit, content
        set all fields accordingly
    }
    void turnOn() {
        send packet to TV telling it to turn on
        if ack received, switch = true
    }
    void turnOff() {
        send packet to TV telling it to turn off
        if ack received, switch = false
    }
    void setContent(String) {
        content = String;
        send packet of new content to TV
    }
    void setTimeLimit(double) {
        timeLimit = double
        send packet of new timeLimit to TV