/* CST8110 - Introduction to Computer Programming
 * Section: 800
 * Semester: 20W
 * Professor: Piyush Jangam
 * Student ID: 040750891
 * Student Email: ross0272@algonquinlive.com
 * Lab 3
 */

public class CodingBatLogic {
    // Returns true if a number is a multiple of 11 or one higher than a multiple of 11
    public boolean specialEleven(int n) {
        if ((n % 11 == 0) || (n % 11 == 1)) {
            return true;
        }
        return false;
    }

    // Checks if we can make GOAL kgs of chocolate given SMALL 1kg bars and BIG 5kg bars
    // If possible, returns the number of small bars used
    // If not possible, returns -1
    public int makeChocolate(int small, int big, int goal) {
        int remainder = goal; //Used to subtract the big bars from the goal
        // Checks if there is a valid number of bars to use
        if ((big >=0) && (small >=0)) {
            // Uses the big bars first by subtracting them from the goal, leaving the remainder
            while ((big > 0) && (remainder >=5)) {
                remainder -=5;
                big--;
            }
            // After the big bars are used, check if there are enough small bars
            if (small >= remainder) {
                return remainder;
            }
        }
        return -1;
    }

    public String seeColor(String str) {
        // Check if the string is long enough for "red"
        if (str.length() >= 3) {
            String firstThree = str.substring(0, 3);
            // Check if the first three letters (or characters) are "red"
            if (firstThree.equals("red")) {
                return "red";
            }
        }
        // Check if the string is long enough for "blue"
        if (str.length() >= 4) {
            String firstFour = str.substring(0, 4);
            // Check if first four letters (or characters) are "blue"
            if (firstFour.equals("blue")) {
                return "blue";
            }
        }
        return "";
    }
}