Sheetl
T em pe r atur aP om ies 2 cze n ia
public class TemperaturaPomieszczenia{ prK/ate finał double TEMP_MAX = 25.0; prk/ate finał double TEMP_MIN = 15.0; prk/ate double temperatura; public staticvoid main(StringQ args){
TemperaturaPomieszczeniakuchnia = new TemperaturaPomies zczenia^); Sys te m. out. printlnf’ELEKTRONICZNY REGULATOR TEMPERATURY’); tr y{k u chn ia.us taw Tern pe ratu re( 19.6);
Sys te m. out. pri ntln( k u chn ia.p o bie rz Te mp e r atu re())} catch(TemperaturaException e){System.outprintln(e.getMess age())) try{k u chn ia.us taw T em pe ratu re( 17.2); System.out.priritln(kuchnia.pobierzTemperature());} catch(TemperaturaException e){Sys tern. out println(e.getMess age());} try{k u chn ia.us taw T em pe ratu re(27.4);
Sys te m. out. pri ntln( k u chn ia.p o bie rz Te mp e r atu re())} catch(TemperaturaException e XSys tern. out println(e.g etMes s age());} łi tu zmieQ i odczytaj temp.
public void us taw Temp erature^ double temp) throws TemperaturaException { if ((temp < TEMP_MIN) || (temp > TEMP_MAX)X throw new TemperaturaExceptior<);
>else{
temperatura = temp;
}
public double pobierzTemperature(X return temperatura;
class TemperaturaExceptjon extends Exception{ public TemperaturaException(){
s up er(" Tem pe ratur a p oz a d o pus 2 cz aJnym z akr es e m.");
public Tern pe ratur a£xception(String komunikaty super( komunikat);
Page 1