gpt-3.5-turbo-0301· OpenAI
WildChat-4.8M (AI2)
Pre nasledujúce rozhranie a triedu naprogramujte adaptér, ktorý mapuje citaj na meraj…
- User
Pre nasledujúce rozhranie a triedu naprogramujte adaptér, ktorý mapuje citaj na meraj pričom skontroluje, či je teplomer zapnutý a ak nie je tak ho zapne. Vhodne ošetrite výnimky.
public interface Senzor {
public int stav(); public int citaj() throws IllegalStateException;}
public class Teplomer {
private boolean zapnuty; public void zapni() { zapnuty = true; } public boolean stav() { return zapnuty; } public int meraj() throws Exception { return 10; }}
- Assistant
public class TeplomerAdapter implements Senzor { private Teplomer teplomer;
public TeplomerAdapter(Teplomer teplomer) { this.teplomer = teplomer; if(!teplomer.stav()) { teplomer.zapni(); } } public int stav() { return teplomer.stav() ? 1 : 0; } public int citaj() throws IllegalStateException { try { return teplomer.meraj(); } catch (Exception e) { throw new IllegalStateException("Chyba pri čítaní hodnoty z teplomeru.", e); } }}
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.