Różnice

Różnice między wybraną wersją a wersją aktualną.

Odnośnik do tego porównania

Both sides previous revision Poprzednia wersja
pl:miw:miw08_ruleruntimeo:thermostatmodel [2008/06/01 00:16]
miw
pl:miw:miw08_ruleruntimeo:thermostatmodel [2019/06/27 15:50] (aktualna)
Linia 1: Linia 1:
 +Implementacja obiektu thermostatModel z przykładu [[pl:​miw:​miw08_ruleruntimeo:​mvcthermostate|Termostat w modelu MVC]]
  
 +<code prolog>
 +
 +:​-object(thermostatModel,​ imports(properties)).
 +:​-public(get_temp/​4).
 +
 +
 +get_temp(Hour,​ Day, Month, T):-
 + checkDayTime(Hour),​
 + season(S,​Month),​
 + checkWorkingTime(Day,​ Hour, O),
 + temperature(S,​ O, T),
 + write(T).
 +
 +checkWorkingTime(Day,​ Hour, O):-
 + workday(Day),​
 + Hour =< 17,
 + Hour >= 9,
 + operation(O,​0).
 +
 +checkWorkingTime(Day,​ Hour, O):-
 + workday(Day),​
 + Hour < 9,
 + operation(O,​ 1).
 +
 +checkWorkingTime(Day,​ Hour, O):-
 + workday(Day),​
 + Hour > 17,
 + operation(O,​ 1).
 +
 +checkWorkingTime(Day,​ _, O):-
 + \+ workday(Day),​
 + weekday(_, Day),
 + operation(O,​ 1).
 +checkDayTime(Hour):​-
 + Hour < 25,
 + Hour > 0.
 +
 +operation(duringWorkingHours,​0).
 +operation(notDuringWorkingHours,​ 1).
 +
 +workday(Day):​-
 + weekday(D, Day),
 + D \= sunday,
 + D \= saturday.
 +
 +weekday(monday,​ 1).
 +weekday(tuesday,​ 2).
 +weekday(wednesday,​ 3).
 +weekday(thursday,​ 4).
 +weekday(friday,​ 5).
 +weekday(saturday,​ 6).
 +weekday(sunday,​ 7).
 +
 +season(winter,​ 1).
 +season(winter,​ 2).
 +season(autumn,​ 3).
 +season(autumn,​ 4).
 +season(autumn,​ 5).
 +season(summer,​ 6).
 +season(summer,​ 7).
 +season(summer,​ 8).
 +season(spring,​ 9).
 +season(spring,​ 10).
 +season(spring,​ 11).
 +season(winter,​ 12).
 +
 +temperature(winter,​ duringWorkingHours,​ T):-
 + T is  18,
 + write('​18 degrees'​).
 +
 +temperature(winter,​ notDuringWorkingHours,​ T):-
 + T is 14,
 + write('​14 degress'​).
 +
 +temperature(autumn,​ duringWorkingHours,​ T):-
 + T is  20,
 + write('​20 degress'​).
 +
 +temperature(autumn,​ notDuringWorkingHours,​ T):-
 + T is 16,
 + write('​16 degress'​).
 +
 +temperature(summer,​ duringWorkingHours,​ T):-
 + T is 24,
 + write('​24 degress'​).
 +
 +temperature(summer,​ notDuringWorkingHours,​ T):-
 + T is 27,
 + write('​27 degress'​).
 +
 +temperature(spring,​ duringWorkingHours,​ T):-
 + T is 20,
 + write('​20 degress'​).
 +
 +temperature(spring,​ notDuringWorkingHours,​ T):-
 + T is 15,
 + write('​15 degress'​).
 +
 +
 +:​-end_object.
 +
 +</​code>​
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0