import java.util.*;
public class Homework4 {
    public static boolean check = true;
    public static int age;
    public static String name;
    public static int currentHunger;
    public static int currentDirtiness;
    public static int currentBoredom;
    public static int hungerRate;
    public static int dirtyRate;
    public static int boredomRate;
    public final static int LOW_STAT_THRESHOLD = 0;
    public final static int MED_STAT_THRESHOLD = 3;
    public final static int HIGH_STAT_THRESHOLD = 6;
    public final static int RUNAWAY_STAT_THRESHOLD = 10;
    public static Scanner input = new Scanner(System.in);
    public static int playerChoice;

    public static void main(String[] args) {
        createPet();
        while (check) {
            agePet();
            choice();
            startStatusPet();
            runAwayCheck();
        }
        resultOfPlayer();
    }
    public static void createPet() {
        age = 0;
        System.out.println("A mysterious egg hatches before you!\nWhat will you name this creature?");
        name = input.nextLine();

        currentHunger = 2;
        currentDirtiness = 6;
        currentBoredom = 5;
        hungerRate = 2;
        dirtyRate = 2;
        boredomRate = 2;
    }
    public static void agePet() {
        age++;
        System.out.println("*********BIRTHDAY UPDATE!*********");
        System.out.println(name + " is now " + age + " days old!");
        if (age % 2 == 0) {
            hungerRate += 1;
            System.out.println(name + " gets hungrier faster!");
        } else if (age % 3 == 0) {
            dirtyRate += 1;
            System.out.println(name + " gets dirtier faster!");
        } else if (age % 5 == 0) {
            boredomRate += 1;
            System.out.println(name + " gets more boring!");
        }
    }
    public static void choice() {
        System.out.println("1.) Feed\n2.) Clean\n3.) Play");
        System.out.println("What would you like to do with " + name + "?");
        playerChoice = input.nextInt();
        if (playerChoice == 1) {
            statusAfterEating();
        } else if (playerChoice == 2) {
            statusAfterCleaning();
        } else {
            statusAfterPlaying();
        }
    }
    private static void statusAfterEating() {
        currentHunger -= hungerRate;
        currentDirtiness += dirtyRate;
        System.out.println("You feed " + name + " but it makes a mess...");
    }
    private static void statusAfterCleaning() {
        currentDirtiness -= dirtyRate;
        currentBoredom += boredomRate;
        System.out.println("You bathe " + name + " but if doesn't like it...");
    }
    private static void statusAfterPlaying() {
        currentBoredom -= boredomRate;
        currentHunger += hungerRate;
        System.out.println("You play with " + name + " and it works up an appetite!");
    }

    public static void startStatusPet() {
        System.out.println("*********CURRENT STATS*********");
        String hungerDescription = "Hunger level: ";
        System.out.println(hungerDescription + statusPet());
        String dirtDescription = "Cleanliness level: ";
        System.out.println(dirtDescription + statusPet());
        String boredDescription = "Boredom level: ";
        System.out.println(boredDescription + statusPet());

    }
    public static String statusPet() {
        String message = null;
        if (currentHunger >= LOW_STAT_THRESHOLD || currentDirtiness >= LOW_STAT_THRESHOLD || currentBoredom >= LOW_STAT_THRESHOLD && currentHunger < MED_STAT_THRESHOLD || currentDirtiness < MED_STAT_THRESHOLD || currentBoredom < MED_STAT_THRESHOLD) {
            message = "Pretty good!";
            return message;
        }
        if (currentHunger >= MED_STAT_THRESHOLD || currentDirtiness >= MED_STAT_THRESHOLD || currentBoredom >= MED_STAT_THRESHOLD && currentHunger < HIGH_STAT_THRESHOLD || currentDirtiness < HIGH_STAT_THRESHOLD || currentBoredom < HIGH_STAT_THRESHOLD) {
            message = "Could be better...";
            return message;
        }
        if (currentHunger >= HIGH_STAT_THRESHOLD || currentDirtiness >= HIGH_STAT_THRESHOLD || currentBoredom >= HIGH_STAT_THRESHOLD && currentHunger < RUNAWAY_STAT_THRESHOLD || currentDirtiness < RUNAWAY_STAT_THRESHOLD || currentBoredom < RUNAWAY_STAT_THRESHOLD) {
            message = "Not good!";
            return message;
        }
        if (currentHunger == RUNAWAY_STAT_THRESHOLD || currentDirtiness == RUNAWAY_STAT_THRESHOLD || currentBoredom == RUNAWAY_STAT_THRESHOLD) {
            message = "The pet has serious problem!";
            return message;
        }
        return message;
    }
    public static void runAwayCheck() {
        if (currentHunger > RUNAWAY_STAT_THRESHOLD) {
            System.out.println("The pet ran away because it was too hungry!");
            check = false;
        }
        if (currentDirtiness > RUNAWAY_STAT_THRESHOLD) {
            System.out.println("The pet ran away because it was too dirty!");
            check = false;
        }
        if (currentBoredom > RUNAWAY_STAT_THRESHOLD) {
            System.out.println("The pet ran away because it was too bored!");
            check = false;
        }
    }
    public static void resultOfPlayer() {
        System.out.println("You took care of " + name + " for " + age + " days");
        if (age < 5) {
            System.out.println("Try to be better next time.");
        } else if (age >= 6 && age <= 15) {
            System.out.println("You spent many days with " + name + "!");
        } else if (age >= 16 && age <= 25) {
            System.out.println("You are great virtual pet owner!");
        } else if (age > 25) {
            System.out.println("Great! You are ready to take care of real pet!");
        }
    }
}