package overloading;

import java.util.Scanner;

public class OverloadingExample1 {

    public final static double DAILY_PAY = 150.0;  // temp employee pay

    public static void main(String[] args) {
        
        // imagine we have two kinds of employes: regular and temporary
        // regular employees pay = hours worked * rate of pay
        // temporary employees pay = $150 per day

        // construct a scanner
        Scanner input = new Scanner(System.in);

        // find out what type of employee we are paying
        System.out.print("Type of employee [R]egular or [T]emporary: ");
        char type = input.next().toUpperCase().charAt(0);

        double pay = 0.0;  // to hold total pay

        // employee is temporary: pay calculated based on # days worked
        if (type == 'T') {
            System.out.print("Enter # of days worked: ");
            double numDays = input.nextDouble();
            pay = calculatePay(numDays); 

        } else { // assume all other inputs are regular employees
            // regular employees get paid by the hour with a specific rate
            System.out.print("Enter hours worked: ");
            double numHours = input.nextDouble();
            System.out.print("Enter rate of pay: ");
            double payRate = input.nextDouble();
            pay = calculatePay(numHours, payRate);
        } 

        input.close(); // done with scanner

        // total pay formatted as currency value
        System.out.printf("Total Pay: $%.2f\n", pay);

        
    }

    // calculate pay for a specific number of days
    public static double calculatePay(double days) {
        return days * DAILY_PAY;
    }

    // calculate pay based on hours worked and rate of pay
    public static double calculatePay(double hours, double rate) {
        return hours * rate;
    }

    /*
     * These would be incorrect:
     * public static double calculatePay(double days) { ... }
     * public static double calculatePay(double hours) { ... }
     * (same parameter list: must differ in type/number)
     * 
     * These would also be incorrect:
     * public static double calculatePay(double days) { ... }
     * public static int calculatePay(double hours) { ... }
     * (same parameter list, even though return types are different)
     * 
     * These are correct:
     * public static double calculatePay(int deptNumber) { ... }
     * public static double calculatePay(double hours, double rate) { ... }
     * public static double calculatePay(double salary) { ... }
     * public static double calculatePay(String deptName) { ... }
     */
}
