Skip to content
TheChatArchiveThe Chat Archive
gpt-3.5-turbo-0301· OpenAIAi2 WildChat-4.8M (AI2)

public class TeplomerAdapter implements Senzor { private Teplomer teplomer; public…

  1. User

    public class TeplomerAdapter implements Senzor {

    private Teplomer teplomer;

    public TeplomerAdapter(Teplomer teplomer) { this.teplomer = teplomer; }

    @Override public int stav() { if (teplomer.stav()) { return 1; } else { return 0; } }

    @Override public int citaj() throws IllegalStateException { if (!teplomer.stav()) { teplomer.zapni(); }

  2. Assistant

    return teplomer.teplota(); }

    @Override public void zapni() { teplomer.zapni(); }

    @Override public void vypni() { teplomer.vypni(); } }

    This is an adapter class that implements the Senzor interface and adapts the Teplomer class to fit that interface. It has a Teplomer object as a field, and all the methods in the Senzor interface are implemented by delegating the call to the appropriate method in the Teplomer object. The TeplomerAdapter class makes it possible to use a Teplomer object in places where a Senzor object is expected.