Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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

image text in transcribed

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

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

Step: 3

blur-text-image

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

Database Driven Web Sites

Authors: Joline Morrison, Mike Morrison

2nd Edition

? 061906448X, 978-0619064488

More Books

Students also viewed these Databases questions