i am designing this my circle class
i. It should contain three private doubles for x, y and radius.
ii. A constructor that accepts three double parameters for x, y, and radius.
iii. A constructor that accepts a MyPoint and a radius. This constructor should
call the constructor in ii.
iv. A no-arg constructor that creates a circle at (0,0) with radius 1. This
constructor should call the constructor in iii.
v. Three get methods for the x, y and radius properties.
vi. Three set methods for the x, y and radius properties.
vii. A method named distance that returns the distance (a double) between this
MyCircle and another MyCircle.
viii. A method named contains that returns true if and only if the MyCircle
contains a MyPoint passed as a parameter.
ix. A method named contains that return true if and only if the MyCircle
completely contains a MyCircle passed as a parameter.
x. A toString method.
xi. A static void main method for testing the MyCircle class
so far i have this code
public class MyCircle {
private double x;
private double y;
private double radius;
public MyCircle(double x, double y, double radius){
this.x = x;
this.y = y;
this.radius = radius;
}
public MyCircle(MyPoint point, double rad){
this.x = point.getX();
this.y = point.getY();
this.radius = rad;
}
public MyCircle(){
this.x = 0;
this.y = 0;
this.radius = 0;
}
public double getX(){
return x;
}
public double getY(){
return y;
}
public double getRadius(){
return radius;
}
public void setX(double x){
this.x = x;
}
public void setY(double y){
this.y = y;
}
public void setRadius(double radius){
this.radius = radius;
}
public double distance(MyCircle other){
double result = 0;
double tmpX = this.x - other.x;
double tmpY = this.y - other.y;
result = Math.sqrt((tmpX*tmpX)*(tmpY*tmpY));
return result;
}
public boolean contains(MyPoint o){
boolean tmp;
double result;
double tmpX = this.x - o.getX();
double tmpY = this.y - o.getY();
System.out.println(tmpX);
System.out.println(o.getX() + " + " + this.x);
result = Math.sqrt((tmpX*tmpX)*(tmpY*tmpY));
System.out.println(result);
if(result < this.radius)
tmp = true;
else
tmp = false;
return tmp;
}
public String toString(){
return "Point x = " + this.x + "\nPoint y = " +this.y
+ "\nRadius = " +this.radius;
}
public static void main(String [] args){
MyPoint p = new MyPoint(1,4);
MyCircle c = new MyCircle(p,3);
System.out.println(c);
MyCircle x = new MyCircle();
boolean tmp = x.contains(p);
System.out.println(tmp);
}
}
and could someone explain the rule ix, thx god bless