package org.academiadecodigo.bootcamp11.arabiannights.genies;

/**
 * MIT License
 * (c) 2017 Ricardo Constantino
 */

public class HappyGenie extends Genie {
    public HappyGenie(int maxWishes) {
        super(maxWishes, GenieType.HAPPY);
    }

    @Override
    public void grantWish(String wish) {
        if (this.getWishesLeft() >= 1) {
            grantOneWish(wish);
            int wishesLeft = this.getWishesLeft();
            if (wishesLeft != 1) {
                System.out.println(this.getGenieType() + ": You have " +
                                   ((wishesLeft != 0) ? wishesLeft : "no") + " wishes left.\n");
                if (wishesLeft == 0) {
                    System.out.println("I'm going back to the lamp.\n");
                }
            } else {
                System.out.println(this.getGenieType() + ": You have one wish left.\n");
            }
        } else {
            System.out.println("\n(the genie went back into the lamp)\n");
        }
    }
}
