gpt-3.5-turbo-0301· OpenAI
WildChat-4.8M (AI2)
2.Vytvorte kompozíciu pre triedu Dom zloženú z izieb a každá izba môže mať vybavenie.…
- User
2.Vytvorte kompozíciu pre triedu Dom zloženú z izieb a každá izba môže mať vybavenie. Izba má mať premenné pre veľkosť (číslo) a názov (reťazec). Vybavenie má mať premenné pre typ (reťazec). Pre triedu miestnosti implementujte rozhranie Comparable tak aby sa miestnosti usporiadali podľa veľkosti vzostupne.
- Assistant
public class Dom { private List<Izba> izby; public Dom() { this.izby = new ArrayList<>(); } public void pridajIzbu(Izba izba) { izby.add(izba); } public List<Izba> getIzby() { return izby; } } public class Izba implements Comparable<Izba> { private int velkost; private String nazov; private Vybavenie vybavenie; public Izba(int velkost, String nazov, Vybavenie vybavenie) { this.velkost = velkost; this.nazov = nazov; this.vybavenie = vybavenie; } @Override public int compareTo(Izba inaIzba) { return Integer.compare(this.velkost, inaIzba.velkost); } public int getVelkost() { return velkost; } public String getNazov() { return nazov; } public Vybavenie getVybavenie() { return vybavenie; } } public class Vybavenie { private String typ; public Vybavenie(String typ) { this.typ = typ; } public String getTyp() { return typ; } }
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.