Consider the following class declarations. Remember that a postcondition describes the result of executing a method.
public class Point
{
private double myX;
private double myY;
//postcondition: this Point has coordinates (0, 0)
public Point()
{ /* implementation not shown */ }
//postcondition: this Point has coordinates (x, y)
public Point(double x, double y)
{ /* implementation not shown */ }
//other methods not shown
}
public class Circle
{
private Point myCenter;
private double myRadius;
//postcondition: this Circle has center at (0, 0) and radius 0.0
public Circle()
{ /* implementation not shown */ }
//postcondition: this Circle has the given center and radius
public Circle(Point center, double radius)
{ /* implementation not shown */ }
//other methods not shown
}
In a separate tester program/class, which of the following correctly declares and initializes Circle circ with center at (29.5, 33.0) and radius of 10.0?
A.
Circle circ = new Circle(29.5, 33.0, 10.0);
B.
Circle circ = new Circle((29.5, 33.0), 10.0);
C.
Point p = new Point(29.5, 33.0);
Circle circ = new Circle(p, 10.0);
D.
Circle circ = new Circle();
circ.myCenter = new Point(29.5, 33.0);
E.
Circle circ = new Circle();
circ.myCenter = new Point();
circ.myCenter.myX = 29.5;
circ.myCenter.myY = 33.0;
circ.myRadius = 10.0;
D
E
B
C
A