Question: Task 1: Implement class Point [30 marks] Given the class private data and public methods below, implement the class methods shown. The class Point. may

 Task 1: Implement class Point [30 marks] Given the class private

Task 1: Implement class Point [30 marks] Given the class private data and public methods below, implement the class methods shown. The class Point. may be used with 20 or 3D coordinates and the default constructor assumes 20 point with coordinates 0,0 . For the method getzl) you have to check that the point is 3D (using the size variable) and print an error message if the size is not 3 and then print the message shown in the sample output and return 1. Task 2: Implement a Java driver method to test the class Point [30 marks] - Declare 3 points, one with each coristructor, and call them point1, point2, and point3. Use the same values as in the sample output when you generate the point objects using the constructors. - Print the details of the 3 points (returned by tostriog) as shown on the standard output (see sample output). Use the getter methods (get X getX and getZ - if needed - to print the coordinates). - Declare a new reference to a Point object and assign it a 4th20 point object and then print this object. - Create a5th and a 6th point objects using new reference names but this time ask the user about the size of the coordinates and then create the appropriate objects based on the user answer ( 2 or 3 use if-else condition). Print the details of these point objects. Use Scanner to get the input from the user. - Try to print the Z coordinate of the 1" point. Task 3: Implement the same class (but use class name Point1 to avoid overwriting the first class) but with the Arraylist type instead of the integer array [ 40 marks] Instead the use of the normal array use an object of Axaylist instead without allocating any size for the Acraxuist. Also no size variable should be used in the class Point1. Use the same driver method to get theoutput of this class which should be the same as before. impore jaxsensid. % public clasa poine I If private data members: a1ze of the point and a pointer to the array of coordinates: private int gize: /l aiae of coordinates for Taak 1 only (no need for Taak3) Drivate int [] data; I/ array to atore coordinatea for Taak one, ArkevLave for Task3 publie Point ();// default clasg constructor (with no arguments) public Point (int x, int y) : (l class constructor to areate a 2D point from arquevents public Point (int x, lnt y, int z):// claa conatructor to create a 3D point froto arguments publrc int gecx (): If member function for getring value of x public int getX (i); fember function for getting value of y pubilc int getzzl): (/ member function for getting value of z (if 1t g present) public String tosting (): / method that returns the String (point: x= present) Sample progran output: /highidghted output from sostsing method rest from main method 19t. Point: x=0y=0 2nd Point: x=1y=2 3rd foint: x=3y=4z=5 4th Point: x=6y= ? What is the 31ze of the point you want to create (2 or 3) 22/1/2.13 prer 1nput 5 th Point: x i y=9 What 15 the 91ze of the point you want to ereate (2 or 3)?3/131s uger input 6ch Point: x=10y=11z=12 Attempt to return a third coordinate of a 2D point Printing 2 coordinate of 2D pointi: 1

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!