Java

OOP GUIDE / WORK

 

POINT CLASS

 

Topics

  • Instance variables
  • Accessing public instance variables

 

 

TASK – PART 1 – POINT CLASS

 

Create the class named Point.  Here are the simple specifications for this very basic class:

 

INSTANCE VARIABLES

 

·       public double x – The x-coordinate of a point.

·       public double y – The y-coordinate of a point.

CONSTRUCTORS & INSTANCE METHODS

 

·       None

 

 

TASK – PART 2 – TESTING THE POINT CLASS

 

Create another class called PointTester and follow the following steps:

 

  • Add a main function to the PointTester class.

  • Inside main, create a few Point objects. 

  • Add the statements required to change the point objects’ x and y values.

  • Output the points’ x and y values to screen.