package staticmethods;

public class Methods2 {
    
    public static void main(String[] args) {

        /*
         * Some methods require arguments (inputs) in order to work.
         * For example, Math.pow() nees 2 arguments: the base and the
         * exponent e.g. Math.pow(5, 2) if you wanted 'five squared'
         * 
         * Arguments require parameter variables defined in the 
         * method header.
         * Parameter variables are LOCAL to the method where they 
         * are defined!
         */

         // go look at this method definition down below, first:
         displayThing("Java", 5);

         /*
          * Return values: a method is allowed to return either 
          * no value (void) or exactly 1 value.
          * If a method returns no value, it must include the return 
          * type "void" in the method header (see the main() method 
          * up above, and the method in Methods1.java for examples)
          * If a method returns a primitive value or object, you 
          * must include the appropriate primitive type or class 
          * type in the method header.
          * Also, inside the method body, you must include a 
          * "return statement" (at least one) to return the actual 
          * value.
          */

          // go look at this method definition down below, first:
          System.out.printf("Area: %.1f\n", cylinderArea(2, 5));
    }

    public static void displayThing(String thing, int numTimes) {
        for (int i = 1; i <= numTimes; i++) {
            System.out.println(thing);
        }
    }

    public static double cylinderArea(double height, double radius) {
        if (height > 0 && radius > 0) {
            // area of circle (PIr^2) * 2 plus area of rectangle
            // area of the rectangle = height * circumference (2PIr)
            return 2 * Math.PI * Math.pow(radius, 2) + 
                height * 2 * Math.PI * radius;
        } else {
            return 0;
        }
        // if you do the returns this way, there must be a return 
        // for every possible branch of the if
    }

    
    
}
