All programs should be in java Thank you Part 1 You will imp

All programs should be in java. Thank you

Part 1:
You will implement a complete class called Point that describes a point as it may be
used in a graphics application. A point consists of an x and y coordinate, and a color.
Here are the specifications:

Solution

public class Point

{

private int x;

private int y;

private String color;

public void setColor(String s)

{

color=s;

}

public void setX(int x)

{this.x=x;}

public void setY(int y)

{

this.y=y;

}

public int getX()

{return x;}

public int getY()

{return y;

}

public int area()

{return 0;

}

Point(int x,int y,Strig c)

{

thus.x=x;

this.y=y;

color=c;

}

public String toString()

{

return \"x:\"+x+\"y:\"+y+\"color:\"+color;

}

public void translate(int dx,int dy)

{

x=x+dx;

y=y+dy;

}

}

Part 2

public class Circle extends Point

{

private int radius;

public void setRadius(int r)

{

radius=r;

}

public int getRadius()

{return radius;}

public double area()

{

return 3.14*radius*radius;

}

Circle(int r,int x,int y,String color)

{radius=r;

super(x,y,color);

}

public void scaleFactor(int factor)

{radius=radius*factor;

}

public String toString()

{

return \"radius:\"+radius+\" \"+super().toString();

}

}

Part 3

public class Driver

{

public static void main(String args[])

{

Circle[] c=new Circle[3];

Circle c1=new Circle(1,2,3,\"blue\");

Circle c2=new Circle(4,5,6,\"red\");

Circle c3=new Circle(7,8,9,\"yelow\");

c[0]=c1;

c[1]=c2;

c[2]=c3;

translateAll(c,2,3);

}

public static void translateAll(Circle[] c,int dx,int dy)

{

for(int i=0;i<c.length;i++)

{

c.translate(dx,dy);

}

}

}

All programs should be in java. Thank you Part 1: You will implement a complete class called Point that describes a point as it may be used in a graphics applic
All programs should be in java. Thank you Part 1: You will implement a complete class called Point that describes a point as it may be used in a graphics applic
All programs should be in java. Thank you Part 1: You will implement a complete class called Point that describes a point as it may be used in a graphics applic

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site