# Dict Mini Project — Pet Shop
# nested dicts, search, buy, availability tracking
# redhorndev.com

# ─────────────────────────────────────────────
# Setup — pre-filled nested dict
# ─────────────────────────────────────────────

shop = {
    "Rex":     {"species": "Dog",    "price": 350.00, "available": True},
    "Whisker": {"species": "Cat",    "price": 180.00, "available": True},
    "Tango":   {"species": "Parrot", "price": 220.00, "available": True},
    "Bubbles": {"species": "Fish",   "price":  25.00, "available": True}
}

# ─────────────────────────────────────────────
# Main loop
# ─────────────────────────────────────────────

while True:
    print("\n1 — View all")
    print("2 — Search")
    print("3 — Buy")
    print("4 — Quit")
    choice = input("Your choice: ")

    if choice == "1":
        print()
        for name, data in shop.items():
            status = "available" if data["available"] else "SOLD"
            print(f"- {name:<10} {data['species']:<8} ${data['price']:>6.2f}   {status}")

    elif choice == "2":
        name = input("Search: ").capitalize()
        if name in shop:
            data = shop[name]
            status = "available" if data["available"] else "SOLD"
            print(f"\n{name} — {data['species']} — ${data['price']:.2f} — {status}")
        else:
            print(f'"{name}" not found.')

    elif choice == "3":
        name = input("Buy: ").capitalize()
        if name in shop:
            if shop[name]["available"]:
                shop[name]["available"] = False    # mark as sold — not removed
                print(f"{name} sold. Good choice.")
            else:
                print(f"{name} is already sold.")
        else:
            print(f'"{name}" not found.')

    elif choice == "4":
        print("Out.")
        break

    else:
        print("Invalid choice. Enter 1 to 4.")
