Question: Hi i am taking a java class and I am stuck on this question Consider the class Point3D2310 below that represents a 3D point as

Hi i am taking a java class and I am stuck on this question

Consider the class Point3D2310 below that represents a 3D point as a 2D point of type Point2D2310 and a z dimension.

public class Point3D2310 implements Cloneable {

private Point2D2310 p;

private int z;

int getZ () { return z; }

void setZ (int newZ) { z = newZ; }

Point2D2310 getP() { return p; }

void setP(Point2D2310 newP) { p = newP; }

/* add your clone method here. */

}

In Point3D2310,

(1) implement a clone method, with the following signature, that creates a deep clone of this 3D point object

public Object clone() throws CloneNotSupportedException

(2) in plain English describe what is the logic behind the implementation of your deep clone method.

The implementation of Point2D2310 can be found below. You can modify Point2D2310 to add methods that you may need.

public class Point2D2310 {

private int x;

private int y;

public int getX() { return x; }

public int getY() { return y; }

public void setX(int newX) { x = newX; }

public void setY(int newY) { x = newY; }

}

Submission instructions

1. Copy and paste your Point3D2310.java in the provided textbox.

2. Copy and paste your Point2D2310.java in the provided textbox as well, if you have modified this class. Do not copy and paste if you have not modified this class.

3. Your code should compile and run without any errors.

4. main and test methods should not be submitted and not needed.

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!