public class Tenant {

    private Home home;
    private int appetite;

    // Constructs a Tenant who eats `ap' grams of gruel per meal
    public Tenant(int ap) {
        appetite = ap;
    }

    // Sets this Tenant's home to be `h'
    public void setHome(Home h) {
        home = h;
    }

    // Returns the address of this Tenant based on its home
    public String getAddress() {
        return home.getAddress();
    }

    // Adds `grams' of gruel to this Tenant's home
    public void buyGruel(int grams) {
        home.adjustGruelBy(grams);
    }

    // Eats a meal of gruel, adjusting the amount of gruel
    // in this Tenant's home. Assumes there's enough gruel.
    public void eat() {
        home.adjustGruelBy(-appetite);
    }

    // Returns whether there's enough gruel in this Tenant's
    // home for the Tenant to eat a meal
    public boolean canEat() {
        return (home.gruelInFridge() >= appetite);
    }

    // Returns a summary of this Tenant's address and whether
    // they can eat a meal (see `getAddress' and `canEat()')
    public String status() {
        return "Lives at: " + getAddress() + ".\n" +
          "Can eat a meal: " + canEat() + ".";
    }

}
