This repository has been archived on 2023-08-20. You can view files and clone it, but cannot push or open issues or pull requests.
yap-6.3/Logtalk/examples/proxies/proxies.lgt
pmoura 75b2645e3f Logtalk 2.27.1 files.
git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@1580 b08c6af1-5177-4d33-ba66-4b1c6b8b522a
2006-03-26 17:31:34 +00:00

40 lines
753 B
Plaintext

:- object(circle(_Radius, _Color)).
:- public([
radius/1,
color/1,
area/1,
perimeter/1,
print/0]).
radius(Radius) :-
parameter(1, Radius).
color(Color) :-
parameter(2, Color).
area(Area) :-
::radius(Radius),
Area is 3.1415927*Radius*Radius.
perimeter(Perimeter) :-
::radius(Radius),
Perimeter is 2*3.1415927*Radius.
print :-
area(Area), write('area: '), write(Area),
perimeter(Perimeter), write(', perimeter: '), write(Perimeter),
color(Color), write(', color: '), write(Color), nl.
:- end_object.
% parametric object proxies (with an extra argument to represent identity):
circle('#1', 1.23, blue).
circle('#2', 3.71, yellow).
circle('#3', 0.39, green).
circle('#4', 5.74, black).
circle('#5', 8.32, cyan).