Question
Write a client program (also known as a driver, tester). See the Time1Test program in Figure 8.2 of your Deitel book. Use this program as
Write a client program (also known as a driver, tester). See the Time1Test program in Figure 8.2 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. 7. In the PointTest class, a. Print your name, Lab number, and date as the first three lines of output. Hard-code the date...do not use the system date. b. Create an object of type Point using the no-arguments constructor. Call this point1 c. Create a second object of type Point using the two-argument constructor. Call this point2. Use the values of x = 11, y = 24 d. Display point 1 instance variables after a call to point1.toString() e. Display point 2 instance variables after a call to point2.toString() f. Change the x value of point1 to 35 using the set method for the x value of point1 g. Display point 1 instance variables after a call to point1.toString()Lab 1 - Advanced Java The Point Lab - Abstract Data Types and Objects Rev. 1/18/2023 7:58 PM h. Display point 2 instance variables after a call to point2.toString() i. Change the y value of point2 to 13 using the set method for the y value of point2 j. Display point 1 instance variables after a call to point1.toString() k. Display point 2 instance variables after a call to point2.toString()
Goals and Objectives: 1. Write a Java program which can be used as an abstract data type (ADT) 2. Correctly use access modifiers in conjunction with instance variables and instance methods 3. Write overloaded constructors 4. Write programs containing no-argument constructors and constructors with arguments 5. Create get and set methods belonging to abstract data types 6. Demonstrate an understanding of the toString method by using it in a Java program 7. Create objects of your ADT and use these objects to execute the ADT's methods Instructions: Refer to the Time1 class provided in Figure 8.1 in your Deitel book to complete the exercise. 1. Write a Point class. The Point class should be written as an abstract data type. 2. 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. 3. Have 2 constructors for the Point class. a. a no-arguments constructor, set both of the instance variables to 0 (zero). b. a constructor having two arguments, one for each of the two instance variables, set the instance variables to those argument values. 4. Include get and set methods for each of the two instance variables identified in step 2. 5. 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; e.g. "The x coordinate =15". DO NOT print from within the toString methodStep 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