Professional Documents
Culture Documents
// Constructors (overloaded)
/** Constructs a Circle instance with default value for radius and color */
radius = 1.0;
color = "red";
/** Constructs a Circle instance with the given radius and default color */
this.radius = radius;
this.color = color;
return radius;
/**
*/
return color;
}
/**
*/
this.color = color;
/**
*/
this.radius = radius;
Class CircleTest
import java.util.Scanner;
/**
*
*
*/
System.out.println("The first circle is " + c1.getColor() + "and has radius of " + c1.getRadius()
System.out.println("The second circle is " + c2.getColor() + " and has radius of " + c2.getRadius()
c2.setRadius(sc.nextDouble());
c2.setColor(sc.next());
System.out.println("The second circle is now " + c2.getColor() + " and it's radius became " +
c2.getRadius()