Teachpacks for How to Design Classes

A Geometry Library (HtDC)


Add


  import geometry.*
at the top of your Definitions Window to import this library.

This geometry package provides a class for representing positions in a Cartesian world:


                      +----------+
                      | Posn     |
                      +----------+
                      | int x    |
                      | int y    |
                      +----------+

To create an instance of the Posn class, a program must supply two int values: one for its x coordinate of the canvas and the second for its y coordinate.