/*
 * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
 * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
 */
package jan17;

import java.util.Date;
import java.util.Random;

/**
 *
 * @author caleb
 */
public class Circle {
    static int numberOfObjectsRunning;
    double radius;
    public int forEverybody = 0;

    public Circle()
    {
        this(0);
         numberOfObjectsRunning++;
    }

    public Circle(double radius)
    {
         numberOfObjectsRunning++;
        this.radius = radius;
        this.dateOfCreation = new Date();
    }

    /**
     * Get the value of radius
     *
     * @return the value of radius
     */
    public double getRadius()
    {
        return radius;
    }

    /**
     * Set the value of radius
     *
     * @param radius new value of radius
     */
    public void setRadius(double radius)
    {
        this.radius = radius;
    }
    
    private Date dateOfCreation;

    /**
     * Get the value of dateOfCreation
     *
     * @return the value of dateOfCreation
     */
    public Date getDateOfCreation()
    {
        return dateOfCreation;
    }

    public Circle getCircle() {
        return this;
    }
    
  
    /**
     * Set the value of dateOfCreation
     *
     * @param dateOfCreation new value of dateOfCreation
     */
    public void setDateOfCreation(Date dateOfCreation)
    {
        this.dateOfCreation = dateOfCreation;
    }

    public double getArea() {
        return Math.PI * (this.radius * this.radius);
    }

    @Override
    public String toString()
    {
        return "Circle{" + "radius=" + radius + ", dateOfCreation=" + dateOfCreation + '}';
    }
    
    public static void main(String[] args)
    {
        // new Circle objects
        System.out.println("Number of objects: " + Circle.numberOfObjectsRunning);
        Circle c1 = new Circle();
        System.out.println("Number of objects: " + Circle.numberOfObjectsRunning);
        Circle c2 = new Circle(2.0);
        System.out.println("Number of objects: " + Circle.numberOfObjectsRunning);

        // two ways to set the radius
        c1.radius = 10.0;
        c1.setRadius(10.0);

        // two ways to get the radius
        System.out.println("radius of c1: " + c1.radius);
        System.out.println("radius of c1: " + c1.getRadius());

        System.out.println("radius of c1: " + c2.radius);
        System.out.println("radius of c1: " + c2.getRadius());

        // use object's methods
        System.out.println("area of c1: " + c1.getArea());
        System.out.println("area of c2: " + c2.getArea());
        
        System.out.println(c1.getDateOfCreation());
        
        c1.setDateOfCreation(new Date());
        
        System.out.println(c1.getDateOfCreation());
        
        Random rng = new Random();
        System.out.println(rng.nextDouble());
        System.out.println(new java.util.Random().nextInt());
        System.out.println(c1);
        System.out.println(c1.toString());
        System.out.println();
        
        printMultiples(c1, 4);
        System.out.println();
        
        Circle[] ar = new Circle[3];
        ar[0] = c1;
        ar[1] = new Circle(10);
        ar[2] = new Circle(3.8);
        Circle.printArray(ar);
        System.out.println(c1.getCircle());
        
    }

    public static void printArray(Circle[] ar)
    {
        for (Circle ar1: ar) {
            System.out.println(ar1);
        }
    }
    
public static void printMultiples(Circle c, int howManyTimes) {
    for (int i = 0; i < howManyTimes; ++i) {
            System.out.println(c);
}
}

}
