Java

OOP GUIDE / WORK

 

POINT CLASS

 

 

TASK – PART 1 – POINT CLASS

 

Here is the Point class:

 

 

public class Point

{

    public double x;

    public double y;

}

 

 

 

 

TASK – PART 2 – TESTING THE POINT CLASS

 

Here is the PointTester class:

 

 

public class PointTester

{

    public static void main(String[] args)

    {

         Point p = new Point();

         p.x = 5.0;

         p.y = 3.1;

         System.out.println("The x-coord is " + p.x);

         System.out.println("The y-coord is " + p.y);

        

         Point coco = new Point();

         coco.x = 7.2;

         coco.y = 9.5;

         System.out.println("The x-coord is " + coco.x);

         System.out.println("The y-coord is " + coco.y);

    }

}