Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

------------------------------------------------------------- Java ---------------------------------------------- Consider the class Point3D below that represents a 3D point as a 2D point of type Point2D and a z dimension. public

------------------------------------------------------------- Java ----------------------------------------------

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

public class Point3D implements Cloneable {

private Point2D p;

private int z;

int getZ () { return z; }

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

Point2D getP() { return p; }

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

/* add your clone method here. */

}

In Point3D,

(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) describe what is the logic behind the implementation of your deep clone method.

The implementation of Point2D can be found below. You can modify Point2D 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; }

}

if you modifiy Point2D please paste that too

NO MAIN OR TEST METHODS needed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Visual C# And Databases

Authors: Philip Conrod, Lou Tylee

16th Edition

1951077083, 978-1951077082

More Books

Students also viewed these Databases questions