/**
 * CS1101 Take-home Lab #2, Exercise 1: MyCircle.java
 * 
 * This class contains a data member radius, and
 * appropriate constructor, accessor and mutator,
 * and a method to compute the area.
 *
 * This is a corrected version.
 * 
 * Discussion group: <fill in your group number here>
 */

class MyCircle {

    // Data member
    private double radius;

    // Constructor
    // this constructor creates a MyCircle object with zero radius
    public MyCircle( ) {
        radius = 0.0;
        // or any of the following 
        // this.radius = 0.0;
        // getRadius(0.0);
        // this.getRadius(0.0); 
        // Note: 'this' is covered in a later chapter, Chapter 7.
    }
   
    // Accessor for radius 
    public double getRadius() {
        return radius;
    }

    // Mutator for radius 
    public void setRadius(double r) {
        // either change the parameter to something 
        // else like r
        radius = r;
        // or if you choose to keep the parameter as radius,
        // then use the 'this' keyword (covered in Chapter 7): 
        // this.radius = radius;
    }                

    // ********************************************
    // Compute area of a MyCircle object
    // ********************************************
    public double computeArea() {
        return Math.PI * Math.pow(getRadius(), 2.0);
        // using getRadius() is preferred over using radius (why?)
    }

}


