/**
 * 7/5/11
 * Program to demonstrate creating static methods.
 * @author cortney
 */
public class StaticMethods {

    public static void main(String[] args) {
        //variables
        int var1 = 10;
        int var2 = 12;
        int var3 = 2;
        int var4 = 0;

        // These methods do not return anything
        StaticMethods.simpleMethod();
        StaticMethods.oneParamMethod(var1);
        twoParamMethod(var1,var2);

        // These methods return something
        var4 = simpleReturn();
        System.out.println("var4 now has value: " + var4 + "\n");
        var4 = oneParamReturn(var1);
        System.out.println("var4 now has value: " + var4 + "\n");
        var4 = threeParamReturn(var2, var3, var4);
        System.out.println("var4 now has value: " + var4 + "\n");

    }

    // Takes no parameters and returns nothing
    private static void simpleMethod() {

        System.out.println("simpleMethod takes no parameters and returns nothing.\n");
    }

    // Has one parameter and returns nothing
    private static void oneParamMethod(int param1) {

        System.out.println("oneParamMethod has one parameter and returns nothing.");
        System.out.println("\tParameters: " + param1 + "\n");

    }

    // Has two parameters and returns nothing
    private static void twoParamMethod(int param1, int param2) {

        System.out.println("twoParamMethod has two parameters and returns nothing.");
        System.out.println("\tParameters: " + param1 + " " + param2 + "\n");
    }

    // Has no parameters and returns an int
    private static int simpleReturn() {
        int tmp = 20;

        System.out.println("simpleReturn has no parameters and returns an int.");
        System.out.println("\tReturn: " + tmp + "\n");

        return tmp;
    }

    // Has one parameter and returns the value plus 1
    private static int oneParamReturn(int param1) {
        int tmp = param1+1;

        System.out.println("oneParamReturn has one parameter and returns an int.");
        System.out.println("\tParameters: " + param1);
        System.out.println("\tReturn: " + tmp + "\n");
        return tmp;
    }

    // Has one parameter and returns an the sum of the first two minus the third
    private static int threeParamReturn(int param1, int param2, int param3) {
        int tmp = param1+param2-param3;

        System.out.println("threeParamReturn has one parameter and returns an int.");
        System.out.println("\tParameters: " + param1 + " " + param2 + " " + param3);
        System.out.println("\tReturn: " + tmp + "\n");

        return tmp;
    }

}
