Define a Class Point2D
Properies of Point2D:
- x : double (final)
- y : double (final)
Constructors of Point2D:
+ the empty one
+ A constructor taking the two coordinates of a point either as double or as integers
Methods of Point2D
+getX
+getY
+norm2() : double which returns the distance from the origin (the point with coordinates (0,0))
+distanceFrom(Point2D) : double which returns the distance from the given point
+rotateOf(double): Point2D which returns the point obtained by rotating the plane of a given angle (center in the origin)
+rotateOf(double, Point2D): Point2D which returns the point obtained by rotating the plane of a given angle and center a given point
+normalize(): Point2D which returns the point on the straight line passing through the point and the origin which has dinstance 1 form the origin
+translate(double, double):point2D which returns the point obtained by translating on the axes X and Y
+translate(Point2D):point2D which returns the point obtained by translating using the Point2D (vector sum)
/*
Useffull java.lang.Math methods:
public static double toRadiant (double degreeAngle)
public static double toDegree (double radiantAngle)
public static double sin (double radiantAngle)
public static double cos (double radiantAngle)
*/
Define the Class Circle
Properties of Circle:
-radious : double (final)
- center : Point2D (final)
Constructors of Circle:
Define an empty constructor for the unit circle with center the origin
Define an constructor taking a center and a radious
Methods of Circle
+translate(double, double):Circle which returns a circle with the center translated the axes X and Y
+translate(Point2D):Circle which returns a circle with the center translated by the given vector
Define the Class Rectangle
Properties of Rectangle (all final)
-corner: Point2D
-height: double
-width: double
-inclination: double
Define contructors
Define the abstract class RegularPolygon
Properties of RegularPolygon (all final)
-center: point2D
-radious: int;
-numerOfSides: int;
-inclination: double
Define an empty constructor with unique parameter the number of sides and which set the center the origin, radious 1 and the inclination 0
Define a constuctor which takes all the parameters
Methods of RegularPolygon:
+ verticesOf () : ListArray which returns a list of Points2D of the vertices of the polygon
Define the class Square extending RefularPolygon
Define a constructor
Methods of Square:
+ rectangleCast (): Rectangle which return an object of type rectangle