Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Hello I am having errors when I compile, I left my code below Using as reference

ID: 3607691 • Letter: H

Question

Hello I am having errors when I compile, I left my code below

Using as reference the design model below, write the java code for the implementation of the classes

public class Point2D
{
// - denotes private, + denotes public access
// these variables are private and cannot be accessed outside of this class

private float x, y, point ;

// default constructor with no arguments, sets value
public Point2D()
{
this.x = 0.0f;
this.y = 0.0f;

}

// 2nd constructors

public Point2D(float x, float y)
{
this.x = x ;
this.y = y ;
}

// getX

public float getX()
{
return this.x;
}

// setX

public void setX(float x)
{
this.x = x;
}

// getY
public float getY()
{
return this.y;
}

// setY
public void setY(float y)
{
this.y = y;
}

// setXY with x and y lol

public void setXY(float x, float y)
{
this.x = x;
this.y = y;
}

// getXY return 2 element in int array containing x and y

public float[] getXY()
{
float[] result = new float[2];
result[0] = this.x;
result[1] = this.y;

return result;

}

// Return "(x,y)"
public String toString() {
return "(" + this.x + "," + this.y + ")";
}
}

//Point3D class

public class Point3D extends Point2D

{

Private float z;

public Point3D(float x, float y, float z)

{

super(x,y);

this.z = z;

}

public Point3D()

{

super();

this.z = 0.0f;

}

public float getZ()

{

return this.z;

}

public void setZ(float z)

{

this.z = z;

}

public void setXYZ(float x, float y, float z)

{

super(x,y);

}

public String toString()

{

return "(" + super.getX() + "," + super.getY() + "," + this.z + ")";

}

}

Point2D x: float = 0.0f y: float = 0.0f +Point2D(x:float,y:float) +Point2D() +getX():float +setX(x:float)void +getY() :float +setY (y:float) void +setXY(x:float,y:float):void +getXY) :float[2]. toStrine):Strine"(x,y)" Array of (x,y) extends Point3D z:float-0.0f +Point3D(x:float,y:float,z:float) +Point3DO getz():float +setZ(z:flaot) void +setXYZ(x:float,y:flaot,z:float):voidArray of (x,y,z) getXYZ():float[3] +toString():String

Explanation / Answer

Point2D.java

public class Point2D {
// - denotes private, + denotes public access
// these variables are private and cannot be accessed outside of this class
private float x, y;

// default constructor with no arguments, sets value
public Point2D() {
this(0.0f,0.0f);
}

// 2nd constructors
public Point2D(float x, float y) {
this.x = x;
this.y = y;
}

// getX
public float getX() {
return this.x;
}

// setX
public void setX(float x) {
this.x = x;
}

// getY
public float getY() {
return this.y;
}

// setY
public void setY(float y) {
this.y = y;
}

// setXY with x and y lol
public void setXY(float x, float y) {
this.x = x;
this.y = y;
}

// getXY return 2 element in int array containing x and y
public float[] getXY() {
float[] result = new float[2];
result[0] = this.x;
result[1] = this.y;
return result;
}

// Return "(x,y)"
public String toString() {
return "(" + this.x + "," + this.y + ")";
}
}

Point3D.java

//Point3D class
public class Point3D extends Point2D
{
private float z;
public Point3D(float x, float y, float z)
{
super(x,y);
this.z = z;
}
public Point3D()
{
super();
this.z = 0.0f;
}
public float getZ()
{
return this.z;
}
public void setZ(float z)
{
this.z = z;
}

public void setXYZ(float x, float y, float z)
{
setXY(x,y);
this.z = z;
}
  
public float[] getXYZ(float x, float y, float z)
{
float[] result = new float[3];
result[0] = this.getX();
result[1] = this.getY();
result[2] = this.getZ();
return result;
}
public String toString()
{
return "(" + super.getX() + "," + super.getY() + "," + this.z + ")";
}
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote