Polygon - A simple demo for a one-to-many association (/examples).
1.00
This example is taken from Rumbaughs book, chapter 3.
A Polygon consist of at least 3 Points (many). In this simple demo there is no checking on the minimum number of Points implemented.
The purpose is to show, how the one-to-many direction could be implemented in Perl. It turns out that there is no need to have an explicit variable $a_has, like in the one-to-one case (cf ../one-to-one).
Instead, the internal list @points takes this functionality. Each index of this array is a unique identifier of an individual Point-instance. See Polygon->add() for details.
You may think of further extensions of this simple Polygon class. E.g. the Polygon could have a name. It could calculate its perimeter, area etc.
perldoc classgen perldoc many perldoc Point
Name: Michael Schlueter
email: mschlue@cpan.org
Copyright (c) 2000, Michael Schlueter. All Rights Reserved. This module is free software. It may be used, redistributed and/or modified under the same terms as Perl itself.
To install Class::Classgen::New, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Class::Classgen::New
CPAN shell
perl -MCPAN -e shell install Class::Classgen::New
For more information on module installation, please visit the detailed CPAN module installation guide.