Logtalk 2.25.0 files.
git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@1288 b08c6af1-5177-4d33-ba66-4b1c6b8b522a
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
=================================================================
|
||||
Logtalk - Object oriented extension to Prolog
|
||||
Release 2.24.0
|
||||
Release 2.25.0
|
||||
|
||||
Copyright (c) 1998-2005 Paulo Moura. All Rights Reserved.
|
||||
=================================================================
|
||||
@@ -10,4 +10,4 @@ To load this example and for sample queries, please see the SCRIPT
|
||||
file.
|
||||
|
||||
For a description of this example, please see the comments in the
|
||||
engines.mlgt metafile.
|
||||
engines.lgt source file.
|
||||
|
@@ -1,6 +1,6 @@
|
||||
=================================================================
|
||||
Logtalk - Object oriented extension to Prolog
|
||||
Release 2.24.0
|
||||
Release 2.25.0
|
||||
|
||||
Copyright (c) 1998-2005 Paulo Moura. All Rights Reserved.
|
||||
=================================================================
|
||||
|
67
Logtalk/examples/engines/engines.lgt
Normal file
67
Logtalk/examples/engines/engines.lgt
Normal file
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
This is a simple example of category composition, i.e. importation of
|
||||
categories by other categories in order to provide modified components
|
||||
for building objects, using car engines.
|
||||
|
||||
The example defines a car engine protocol (enginep), a standard engine
|
||||
(classic), and an improved version of it (sport). Both engines are then
|
||||
imported in two car models (sedan and coupe).
|
||||
*/
|
||||
|
||||
|
||||
% first we define a protocol for describing the characteristics of an engine:
|
||||
|
||||
:- protocol(enginep).
|
||||
|
||||
:- public(reference/1).
|
||||
:- public(capacity/1).
|
||||
:- public(cylinders/1).
|
||||
:- public(horsepower_rpm/2).
|
||||
:- public(bore_stroke/2).
|
||||
:- public(fuel/1).
|
||||
|
||||
:- end_protocol.
|
||||
|
||||
|
||||
% second, we can define a typical engine as a category, which will be used
|
||||
% when "assembling" cars:
|
||||
|
||||
:- category(classic,
|
||||
implements(enginep)).
|
||||
|
||||
reference('M180.940').
|
||||
capacity(2195).
|
||||
cylinders(6).
|
||||
horsepower_rpm(94, 4800).
|
||||
bore_stroke(80, 72.8).
|
||||
fuel(gasoline).
|
||||
|
||||
:- end_category.
|
||||
|
||||
|
||||
% next, we define a souped up version of the previous engine, which differs
|
||||
% from the standard one only in its reference and in its horsepower:
|
||||
|
||||
:- category(sport,
|
||||
imports(classic)).
|
||||
|
||||
reference('M180.941').
|
||||
horsepower_rpm(110, 5000).
|
||||
|
||||
:- end_category.
|
||||
|
||||
|
||||
% with engines (and other components), we may start "assembling" some cars:
|
||||
|
||||
:- object(sedan,
|
||||
imports(classic)).
|
||||
|
||||
|
||||
:- end_object.
|
||||
|
||||
|
||||
:- object(coupe,
|
||||
imports(sport)).
|
||||
|
||||
|
||||
:- end_object.
|
Reference in New Issue
Block a user