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/points/bounded_history_point.lgt
pmoura 75392e54c7 Logtalk 2.15.0 release files.
git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@757 b08c6af1-5177-4d33-ba66-4b1c6b8b522a
2003-02-05 00:15:28 +00:00

55 lines
1.0 KiB
Plaintext

:- object(bounded_history_point,
imports(bounded_coordinate, point_history),
instantiates(class),
specializes(point)).
:- info([
version is 1.1,
date is 2000/10/31,
author is 'Paulo Moura',
comment is 'Two dimensional point moving in a constrained area and remembering past point positions.',
source is 'Example adopted from the SICStus Objects documentation.']).
move(X, Y) :-
::check_bounds(x, X),
::check_bounds(y, Y),
::position(OldX, OldY),
^^move(X, Y),
::add_to_history((OldX, OldY)).
print :-
::print_bounds(x),
::print_bounds(y),
::print_history,
^^print.
instance_base_name(bhp).
default_init_option(history-[]).
default_init_option(bounds(x)-(-10, 10)).
default_init_option(bounds(y)-(-10, 10)).
default_init_option(Default) :-
^^default_init_option(Default).
process_init_option(history-History) :-
::init_history(History).
process_init_option(bounds(Coordinate)-(Min, Max)) :-
::set_bounds(Coordinate, Min, Max).
process_init_option(Option) :-
^^process_init_option(Option).
:- end_object.