Logtalk 2.15.0 release files.
git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@757 b08c6af1-5177-4d33-ba66-4b1c6b8b522a
This commit is contained in:
10
Logtalk/examples/shapes/ph/NOTES
Normal file
10
Logtalk/examples/shapes/ph/NOTES
Normal file
@@ -0,0 +1,10 @@
|
||||
=================================================================
|
||||
Logtalk - Object oriented extension to Prolog
|
||||
Release 2.15.0
|
||||
|
||||
Copyright (c) 1998-2003 Paulo Moura. All Rights Reserved.
|
||||
=================================================================
|
||||
|
||||
|
||||
To load all objects in this example consult the ph.loader utility
|
||||
file (note that the *.loader files are Prolog files).
|
35
Logtalk/examples/shapes/ph/SCRIPT
Normal file
35
Logtalk/examples/shapes/ph/SCRIPT
Normal file
@@ -0,0 +1,35 @@
|
||||
=================================================================
|
||||
Logtalk - Object oriented extension to Prolog
|
||||
Release 2.15.0
|
||||
|
||||
Copyright (c) 1998-2003 Paulo Moura. All Rights Reserved.
|
||||
=================================================================
|
||||
|
||||
|
||||
| ?- square::nsides(N).
|
||||
|
||||
N = 4
|
||||
yes
|
||||
|
||||
|
||||
| ?- square::area(A).
|
||||
|
||||
A = 1
|
||||
yes
|
||||
|
||||
|
||||
| ?- q1::(color(Color), side(Side), position(X, Y)).
|
||||
|
||||
Color = red
|
||||
Side = 1
|
||||
X = 0
|
||||
Y = 0
|
||||
yes
|
||||
|
||||
|
||||
| ?- q2::(side(Side), area(Area), perimeter(Perimeter)).
|
||||
|
||||
Side = 3
|
||||
Area = 9
|
||||
Perimeter = 12
|
||||
yes
|
9
Logtalk/examples/shapes/ph/ph.loader
Normal file
9
Logtalk/examples/shapes/ph/ph.loader
Normal file
@@ -0,0 +1,9 @@
|
||||
|
||||
:- initialization(
|
||||
logtalk_load([
|
||||
shape,
|
||||
polygon,
|
||||
regular_polygon,
|
||||
square,
|
||||
q1,
|
||||
q2])).
|
51
Logtalk/examples/shapes/ph/polygon.lgt
Normal file
51
Logtalk/examples/shapes/ph/polygon.lgt
Normal file
@@ -0,0 +1,51 @@
|
||||
:- object(polygon,
|
||||
extends(shape)).
|
||||
|
||||
|
||||
:- info([
|
||||
author is 'Paulo Moura',
|
||||
version is 1.0,
|
||||
date is 2003/2/3,
|
||||
comment is 'Generic polygon.']).
|
||||
|
||||
|
||||
:- public(nsides/1).
|
||||
|
||||
:- mode(nsides(?integer), zero_or_one).
|
||||
|
||||
:- info(nsides/1, [
|
||||
comment is 'Polygon number of sides.',
|
||||
argnames is ['Number']]).
|
||||
|
||||
|
||||
:- public(area/1).
|
||||
|
||||
:- mode(area(-float), zero_or_one).
|
||||
|
||||
:- info(area/1, [
|
||||
comment is 'Polygon area.',
|
||||
argnames is ['Area']]).
|
||||
|
||||
|
||||
:- public(perimeter/1).
|
||||
|
||||
:- mode(perimeter(?atom), zero_or_one).
|
||||
|
||||
:- info(perimeter/1, [
|
||||
comment is 'Polygon perimeter.',
|
||||
argnames is ['Perimeter']]).
|
||||
|
||||
|
||||
:- public(side/1).
|
||||
|
||||
:- mode(side(?atom), zero_or_one).
|
||||
|
||||
:- info(side/1, [
|
||||
comment is 'Polygon side length.',
|
||||
argnames is ['Length']]).
|
||||
|
||||
|
||||
side(1). % default side length
|
||||
|
||||
|
||||
:- end_object.
|
5
Logtalk/examples/shapes/ph/q1.lgt
Normal file
5
Logtalk/examples/shapes/ph/q1.lgt
Normal file
@@ -0,0 +1,5 @@
|
||||
:- object(q1,
|
||||
extends(square)).
|
||||
|
||||
|
||||
:- end_object.
|
14
Logtalk/examples/shapes/ph/q2.lgt
Normal file
14
Logtalk/examples/shapes/ph/q2.lgt
Normal file
@@ -0,0 +1,14 @@
|
||||
:- object(q2,
|
||||
extends(square)).
|
||||
|
||||
|
||||
position(2, 3).
|
||||
|
||||
|
||||
color(blue).
|
||||
|
||||
|
||||
side(3).
|
||||
|
||||
|
||||
:- end_object.
|
18
Logtalk/examples/shapes/ph/regular_polygon.lgt
Normal file
18
Logtalk/examples/shapes/ph/regular_polygon.lgt
Normal file
@@ -0,0 +1,18 @@
|
||||
:- object(regular_polygon,
|
||||
extends(polygon)).
|
||||
|
||||
|
||||
:- info([
|
||||
author is 'Paulo Moura',
|
||||
version is 1.0,
|
||||
date is 2003/2/3,
|
||||
comment is 'Generic regular polygon.']).
|
||||
|
||||
|
||||
perimeter(Perimeter) :-
|
||||
::nsides(Number),
|
||||
::side(Side),
|
||||
Perimeter is Number*Side.
|
||||
|
||||
|
||||
:- end_object.
|
35
Logtalk/examples/shapes/ph/shape.lgt
Normal file
35
Logtalk/examples/shapes/ph/shape.lgt
Normal file
@@ -0,0 +1,35 @@
|
||||
:- object(shape).
|
||||
|
||||
|
||||
:- info([
|
||||
author is 'Paulo Moura',
|
||||
version is 1.0,
|
||||
date is 2003/2/3,
|
||||
comment is 'Generic geometric shape.']).
|
||||
|
||||
|
||||
:- public(color/1).
|
||||
|
||||
:- mode(color(?atom), zero_or_one).
|
||||
|
||||
:- info(color/1, [
|
||||
comment is 'Shape color.',
|
||||
argnames is ['Color']]).
|
||||
|
||||
|
||||
:- public(position/2).
|
||||
|
||||
:- mode(position(?integer, ?integer), zero_or_one).
|
||||
|
||||
:- info(position/2, [
|
||||
comment is 'Shape position.',
|
||||
argnames is ['X', 'Y']]).
|
||||
|
||||
|
||||
color(red). % default shape color
|
||||
|
||||
|
||||
position(0, 0). % default shape position
|
||||
|
||||
|
||||
:- end_object.
|
20
Logtalk/examples/shapes/ph/square.lgt
Normal file
20
Logtalk/examples/shapes/ph/square.lgt
Normal file
@@ -0,0 +1,20 @@
|
||||
:- object(square,
|
||||
extends(regular_polygon)).
|
||||
|
||||
|
||||
:- info([
|
||||
author is 'Paulo Moura',
|
||||
version is 1.0,
|
||||
date is 2003/2/3,
|
||||
comment is 'Geometric square.']).
|
||||
|
||||
|
||||
nsides(4).
|
||||
|
||||
|
||||
area(Area) :-
|
||||
::side(Side),
|
||||
Area is Side*Side.
|
||||
|
||||
|
||||
:- end_object.
|
Reference in New Issue
Block a user