Answered step by step
Verified Expert Solution
Question
1 Approved Answer
1 . Write a Point class. The Point class should be written as an abstract data type. 2 . Include the following instance variables: a
Write a Point class. The Point class should be written as an abstract data type.
Include the following instance variables:
a an integer representing the x coordinate
b an integer representing the y coordinate
c The instance variables in your program should only be directly accessible inside of the Point
class.
Have constructors for the Point class.
a a noarguments constructor, set both of the instance variables to zero
b a constructor having two arguments, one for each of the two instance variables, set the instance
variables to those argument values.
Include get and set methods for each of the two instance variables identified in step
Include a toString method in your Point class. The toString method should be accessible to any program
and should return the values of the two instance variables. Values must be labeled; egThe xcoordinate DO NOT print from within the toString method.
Write a client program also known as a driver, tester See the TimeTest program in Figure of
your Deitel book. Use this program as a model to write your program. Your program will have the
same intent but will follow the procedure as outlined below. Name your program PointTest.
In the PointTest class,
a Print your name, Lab number, and date as the first three lines of output. Hardcode the date...do
not use the system date.
b Create an object of type Point using the noarguments constructor. Call this point
c Create a second object of type Point using the twoargument constructor. Call this point Use
the values of x y
d Display point instance variables after a call to pointtoString
e Display point instance variables after a call to pointtoString
f Change the x value of point to using the set method for the x value of point
g Display point instance variables after a call to pointtoString
Lab Advanced Java
The Point Lab Abstract Data Types and Objects
Rev. : PM
h Display point instance variables after a call to pointtoString
i Change the y value of point to using the set method for the y value of point
j Display point instance variables after a call to pointtoString
k Display point instance variables after a call to pointtoString
Here is an example of the output. Your version may vary, though your values should match mine.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started