/**
 * House: A potential house on the market. The status may be sold, listed,
 * or unlisted. Maintains price, address, buyer, and status.
 */
public class House {


    /** The price of this House. */
    private int price;

    /**
     * Whether this house is "listed", "unlisted", or "sold". If
     * "unlisted", 'price' and 'buyer' are invalid. If "listed", then
     * price holds the asking price and only 'buyer' is invalid.
     */
    private String status = "unlisted";

    /** Who bought the house. (irrelevant if no buyer yet) */
    private String buyer;   
 

    /** Set this House's address to a. */
    public void setAddress(String a) {
        address = a;
    }

    // ----------------------------------------------------------------
    // Fill in these missing pieces.

    /** This House's address. */
    private String address;


    /** Sell this House to buyer b. */
    public void sell(String b) {
        buyer = b;
        status = "sold";
    }


    /** Register this House as listed, and set the asking price to p. */
    public void list(int p) {
        price = p;
        status = "listed";
    }


    /** Change the asking price of this House by amount a. */
    public void adjustAskingPrice(int a) {
        price += a;
    }


    /** Unlist this House. */
    public void unlist() {
        status = "unlisted";
        buyer = "";          // this is optional 
        price = 0;           // this is also optional
    }
    
    /** Return the price of this House. */
    public int getPrice() {
        return price;
    }

    // ----------------------------------------------------------------


    /** Return a String representation of this House. 
     *  students: Do not change this method!
     */
    public String toString() {
        String result = address + " " + status;

        if (status.equals("listed")) {
            result += " at $" + price;
        } else if (status.equals("sold")) {
            result += " to " + buyer +" for $" + price;
        }

        return result;
    }

}
