Question: write test circle class package inh; public class Circle extends Point{ private String n; private double r,a,c; Circle(){ super (); n=C; r=1; } Circle( double

write test circle class

package inh;

public class Circle extends Point{

private String n;

private double r,a,c;

Circle(){

super();

n="C";

r=1;

}

Circle(double r, String n, double x, double y, String ptName){

super(x,y,ptName);

this.r=r;

this.n=n;

}

public void setr(double r) {

this.r=r;

}

public void setn(String n) {

this.n=n;

}

public double getr() {

return r;

}

public String getn() {

return n;

}

public String toString() {

return super.toString() +" radius is "+r + " name of circle" +n;

}

public void computea() {

a=Math.PI*r*r;

}

public void computec() {

c=2*Math.PI*r;

}

public boolean equals(Circle c) {

Point p=new Point(c.getx(),c.gety());

return super.equals(p) && this.r==r;

}

}

package inh;

public class Point {

private double x,y;

private String name="";

Point(){ // default constructor

name="P";

x=0;

y=0;

}

Point(double x, double y){

this();

this.x=x;

this.y=y;

}

Point(double x, double y, String n){

this(x,y);

name=n;

}

Point(String n){

name=n;

}

public void setx(double x) { // mutator method

this.x =x;

}

public void sety(double y) {

this.y =y;

}

public double getx() {

return x;

}

public double gety() { // accessor

return y;

}

public void setN(String n) {

name=n;

}

public String getN() {

return name;

}

public String toString() {

String s=name +"(" + x +"," +y +")";

return s;

}

public boolean equals(Point p) {

return (this.x==p.x && this.y==p.y);

}

public double dist(Point p) {

return Math.sqrt((this.x-p.x)*(this.x-p.x) +(this.y -p.y)*(this.y -p.y));

}

}

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!