________________________________________________________________________

This file is part of Logtalk <https://logtalk.org/>  
SPDX-FileCopyrightText: 1998-2023 Paulo Moura <pmoura@logtalk.org>  
SPDX-License-Identifier: Apache-2.0

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
________________________________________________________________________


% start by loading the design pattern sample implementations:

| ?- logtalk_load(design_patterns('structural/composite/loader')).
...


% first, create some ellipses:

| ?- ellipse::(new(e1), new(e2), new(e3), new(e4)).

yes


% second, create some composite graphics:

| ?- composite_graphic::(new(cg), new(cg1), new(cg2)).

yes


% add to the composite graphic cg1 the ellipses e1, e2, and e3:

| ?- cg1::(add(e1), add(e2), add(e3)).

yes


% add to the composite graphic cg2 the ellipse e4:

| ?- cg2::add(e4).

yes


% add to the composite graphic cg the composite graphics cg1 and cg2:

| ?- cg::(add(cg1), add(cg2)).

yes


% finally, print the contents of the top-level composite graphic cg:

| ?- cg::print.

ellipse: e1
ellipse: e2
ellipse: e3
ellipse: e4
yes
