package hws.hw1;

/**
 * A program that can be used to test the PizzaPricer class.
 *
 * @author CS159 Faculty
 * @version 08/20/2025
 */
public class PizzaPricerTest {

    /**
     * The entry point of the driver.
     *
     * @param args The command-line arguments (which are ignored)
     */
    public static void main(String[] args) {

        System.out.println("\n");
        System.out.println("Testing PizzaPricer.numberOfFullBoxes()");
        System.out.printf("%s: %d\n", describe(0), PizzaPricer.numberOfFullBoxes(0));
        System.out.printf("%s: %d\n", describe(1), PizzaPricer.numberOfFullBoxes(1));
        System.out.printf("%s: %d\n", describe(7), PizzaPricer.numberOfFullBoxes(7));
        System.out.printf("%s: %d\n", describe(8), PizzaPricer.numberOfFullBoxes(8));
        System.out.printf("%s: %d\n", describe(9), PizzaPricer.numberOfFullBoxes(9));
        System.out.printf("%s: %d\n", describe(16), PizzaPricer.numberOfFullBoxes(16));
        System.out.printf("%s: %d\n", describe(18), PizzaPricer.numberOfFullBoxes(18));
        System.out.printf("%s: %d\n", describe(23), PizzaPricer.numberOfFullBoxes(23));

        System.out.println("\n");
        System.out.println("Testing PizzaPricer.needAnExtraBox()");
        System.out.printf("%s: %b\n", describe(0), PizzaPricer.needAnExtraBox(0));
        System.out.printf("%s: %b\n", describe(1), PizzaPricer.needAnExtraBox(1));
        System.out.printf("%s: %b\n", describe(7), PizzaPricer.needAnExtraBox(7));
        System.out.printf("%s: %b\n", describe(8), PizzaPricer.needAnExtraBox(8));
        System.out.printf("%s: %b\n", describe(9), PizzaPricer.needAnExtraBox(9));
        System.out.printf("%s: %b\n", describe(16), PizzaPricer.needAnExtraBox(16));
        System.out.printf("%s: %b\n", describe(18), PizzaPricer.needAnExtraBox(18));
        System.out.printf("%s: %b\n", describe(23), PizzaPricer.needAnExtraBox(23));

        System.out.println("\n");
        System.out.println("Testing PizzaPricer.numberOfBoxes()");
        System.out.printf("%s: %d\n", describe(0), PizzaPricer.numberOfBoxes(0));
        System.out.printf("%s: %d\n", describe(1), PizzaPricer.numberOfBoxes(1));
        System.out.printf("%s: %d\n", describe(7), PizzaPricer.numberOfBoxes(7));
        System.out.printf("%s: %d\n", describe(8), PizzaPricer.numberOfBoxes(8));
        System.out.printf("%s: %d\n", describe(9), PizzaPricer.numberOfBoxes(9));
        System.out.printf("%s: %d\n", describe(16), PizzaPricer.numberOfBoxes(16));
        System.out.printf("%s: %d\n", describe(18), PizzaPricer.numberOfBoxes(18));
        System.out.printf("%s: %d\n", describe(23), PizzaPricer.numberOfBoxes(23));

        System.out.println("\n");
        System.out.println("Testing PizzaPricer.numberOfExtras()");
        System.out.printf("%s: %d\n", describe(0), PizzaPricer.numberOfExtras(0));
        System.out.printf("%s: %d\n", describe(1), PizzaPricer.numberOfExtras(1));
        System.out.printf("%s: %d\n", describe(7), PizzaPricer.numberOfExtras(7));
        System.out.printf("%s: %d\n", describe(8), PizzaPricer.numberOfExtras(8));
        System.out.printf("%s: %d\n", describe(9), PizzaPricer.numberOfExtras(9));
        System.out.printf("%s: %d\n", describe(16), PizzaPricer.numberOfExtras(16));
        System.out.printf("%s: %d\n", describe(18), PizzaPricer.numberOfExtras(18));
        System.out.printf("%s: %d\n", describe(23), PizzaPricer.numberOfExtras(23));

        System.out.println("\n");
        System.out.println("Testing PizzaPricer.priceFor()");
        System.out.printf("%s: %5.2f\n", describe(0), PizzaPricer.priceFor(0));
        System.out.printf("%s: %5.2f\n", describe(1), PizzaPricer.priceFor(1));
        System.out.printf("%s: %5.2f\n", describe(7), PizzaPricer.priceFor(7));
        System.out.printf("%s: %5.2f\n", describe(8), PizzaPricer.priceFor(8));
        System.out.printf("%s: %5.2f\n", describe(9), PizzaPricer.priceFor(9));
        System.out.printf("%s: %5.2f\n", describe(16), PizzaPricer.priceFor(16));
        System.out.printf("%s: %5.2f\n", describe(18), PizzaPricer.priceFor(18));
        System.out.printf("%s: %5.2f\n", describe(23), PizzaPricer.priceFor(23));

        System.out.println("\n");
        System.out.println("Testing PizzaPricer.canApplyCoupon()");
        System.out.printf("%s: %b\n", describe(0) + " with correct discount code", PizzaPricer.canApplyCoupon(0, "WELCOME-BACK"));
        System.out.printf("%s: %b\n", describe(1) + " with correct discount code", PizzaPricer.canApplyCoupon(1, "WELCOME-BACK"));
        System.out.printf("%s: %b\n", describe(1) + " with incorrect discount code",  PizzaPricer.canApplyCoupon(1, "WELCOME"));
        System.out.printf("%s: %b\n", describe(7) + " with correct discount code", PizzaPricer.canApplyCoupon(7, "WELCOME-BACK"));
        System.out.printf("%s: %b\n", describe(8) + " with correct discount code", PizzaPricer.canApplyCoupon(8, "WELCOME-BACK"));
        System.out.printf("%s: %b\n", describe(8) + " with incorrect discount code",  PizzaPricer.canApplyCoupon(8, "WELCOME"));
        System.out.printf("%s: %b\n", describe(9) + " with correct discount code", PizzaPricer.canApplyCoupon(9, "WELCOME-BACK"));
        System.out.printf("%s: %b\n", describe(16) + " with correct discount code", PizzaPricer.canApplyCoupon(16, "WELCOME-BACK"));
        System.out.printf("%s: %b\n", describe(18) + " with correct discount code", PizzaPricer.canApplyCoupon(18, "WELCOME-BACK"));
        System.out.printf("%s: %b\n", describe(23) + " with correct discount code", PizzaPricer.canApplyCoupon(23, "WELCOME-BACK"));
        System.out.printf("%s: %b\n", describe(8) + " with incorrect discount code",  PizzaPricer.canApplyCoupon(8, "WELCOME"));

        System.out.println("\n");
        System.out.println("Testing PizzaPricer.finalPrice()");
        System.out.printf("%s: %5.2f\n", describe(0) + " with correct discount code", PizzaPricer.finalPrice(0, "WELCOME-BACK"));
        System.out.printf("%s: %5.2f\n", describe(1) + " with correct discount code", PizzaPricer.finalPrice(1, "WELCOME-BACK"));
        System.out.printf("%s: %5.2f\n", describe(1) + " with incorrect discount code",  PizzaPricer.finalPrice(1, "WELCOME"));
        System.out.printf("%s: %5.2f\n", describe(7) + " with correct discount code", PizzaPricer.finalPrice(7, "WELCOME-BACK"));
        System.out.printf("%s: %5.2f\n", describe(8) + " with correct discount code", PizzaPricer.finalPrice(8, "WELCOME-BACK"));
        System.out.printf("%s: %5.2f\n", describe(8) + " with incorrect discount code",  PizzaPricer.finalPrice(8, "WELCOME"));
        System.out.printf("%s: %5.2f\n", describe(9) + " with correct discount code", PizzaPricer.finalPrice(9, "WELCOME-BACK"));
        System.out.printf("%s: %5.2f\n", describe(16) + " with correct discount code", PizzaPricer.finalPrice(16, "WELCOME-BACK"));
        System.out.printf("%s: %5.2f\n", describe(18) + " with correct discount code", PizzaPricer.finalPrice(18, "WELCOME-BACK"));
        System.out.printf("%s: %5.2f\n", describe(18) + " with incorrect discount code",  PizzaPricer.finalPrice(18, "WELCOME"));
        System.out.printf("%s: %5.2f\n", describe(23) + " with correct discount code", PizzaPricer.finalPrice(23, "WELCOME-BACK"));
    }

    /**
     * A convenience method that creates a description of a test.
     *
     * @param number The number of Pizzas in the test
     * @return A description of the test
     */
    private static String describe(int number) {
        return String.format("\tFor %2d Pizzas", number);
    }

}
