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/NOTES
Normal file
10
Logtalk/examples/shapes/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.
|
||||
=================================================================
|
||||
|
||||
|
||||
This directory contains two versions, one prototype-based and the
|
||||
other one class-based, of a very simple geometric shapes hierarchy.
|
17
Logtalk/examples/shapes/ch/NOTES
Normal file
17
Logtalk/examples/shapes/ch/NOTES
Normal file
@@ -0,0 +1,17 @@
|
||||
=================================================================
|
||||
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 ch.loader utility
|
||||
file (note that the *.loader files are Prolog files).
|
||||
|
||||
You will need to also load the objects in the "roots" example.
|
||||
|
||||
You will need to consult the following files in the library directory:
|
||||
events.loader, types.loader, and hierarchies.loader. Alternatively, you
|
||||
may load the library/all.loader file to load all library entities.
|
||||
|
31
Logtalk/examples/shapes/ch/SCRIPT
Normal file
31
Logtalk/examples/shapes/ch/SCRIPT
Normal file
@@ -0,0 +1,31 @@
|
||||
=================================================================
|
||||
Logtalk - Object oriented extension to Prolog
|
||||
Release 2.15.0
|
||||
|
||||
Copyright (c) 1998-2003 Paulo Moura. All Rights Reserved.
|
||||
=================================================================
|
||||
|
||||
|
||||
| ?- square::nsides(N).
|
||||
|
||||
! error(
|
||||
existence_error(predicate_declaration, nsides(_)),
|
||||
square::nsides(N),
|
||||
user)
|
||||
|
||||
|
||||
| ?- 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/ch/ch.loader
Normal file
9
Logtalk/examples/shapes/ch/ch.loader
Normal file
@@ -0,0 +1,9 @@
|
||||
|
||||
:- initialization(
|
||||
logtalk_load([
|
||||
shape,
|
||||
polygon,
|
||||
regular_polygon,
|
||||
square,
|
||||
q1,
|
||||
q2])).
|
52
Logtalk/examples/shapes/ch/polygon.lgt
Normal file
52
Logtalk/examples/shapes/ch/polygon.lgt
Normal file
@@ -0,0 +1,52 @@
|
||||
:- object(polygon,
|
||||
instantiates(abstract_class),
|
||||
specializes(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.
|
4
Logtalk/examples/shapes/ch/q1.lgt
Normal file
4
Logtalk/examples/shapes/ch/q1.lgt
Normal file
@@ -0,0 +1,4 @@
|
||||
:- object(q1,
|
||||
instantiates(square)).
|
||||
|
||||
:- end_object.
|
14
Logtalk/examples/shapes/ch/q2.lgt
Normal file
14
Logtalk/examples/shapes/ch/q2.lgt
Normal file
@@ -0,0 +1,14 @@
|
||||
:- object(q2,
|
||||
instantiates(square)).
|
||||
|
||||
|
||||
position(2, 3).
|
||||
|
||||
|
||||
color(blue).
|
||||
|
||||
|
||||
side(3).
|
||||
|
||||
|
||||
:- end_object.
|
19
Logtalk/examples/shapes/ch/regular_polygon.lgt
Normal file
19
Logtalk/examples/shapes/ch/regular_polygon.lgt
Normal file
@@ -0,0 +1,19 @@
|
||||
:- object(regular_polygon,
|
||||
instantiates(abstract_class),
|
||||
specializes(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.
|
37
Logtalk/examples/shapes/ch/shape.lgt
Normal file
37
Logtalk/examples/shapes/ch/shape.lgt
Normal file
@@ -0,0 +1,37 @@
|
||||
:- object(shape,
|
||||
instantiates(abstract_class),
|
||||
specializes(object)).
|
||||
|
||||
|
||||
:- 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.
|
21
Logtalk/examples/shapes/ch/square.lgt
Normal file
21
Logtalk/examples/shapes/ch/square.lgt
Normal file
@@ -0,0 +1,21 @@
|
||||
:- object(square,
|
||||
instantiates(class),
|
||||
specializes(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.
|
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