đŸŖ Tamagotchi Pet Simulator – Java GUI Edition

A fun and interactive Tamagotchi-style virtual pet game built using Java Swing. Feed, play, rest, or ignore your digital pet — but beware! If you neglect it, it might not survive.


đŸŽ¯ Project Goal

Simulate a virtual pet's lifecycle and mood using basic object-oriented programming concepts and a clean graphical user interface (GUI).


🧠 Concepts Used

Java Concept Usage
OOP (Classes, Objects)Pet class with encapsulated data and behavior
Inner ClassesPet is an inner class within TamagotchiGUI
Swing GUI (JFrame, JButton, JLabel)Used for building a functional GUI
Layout Managers (BorderLayout, GridLayout)For organizing GUI components
Event HandlingActionListener to respond to button clicks
User InputJOptionPane for naming the pet
Conditional LogicTo handle game rules, death conditions, and actions
Method AbstractionAll pet actions are modularized into methods (feed(), rest(), etc.)

đŸ•šī¸ How to Play

  1. Run the Program
    Make sure you have Java installed. Compile and run:
    javac TamagotchiGUI.java
    java TamagotchiGUI
  2. Name Your Pet
    A dialog will prompt you to give your pet a name.
  3. Interact
    Use the buttons to feed, play with, or rest your pet.
  4. Monitor Its Stats
  5. Game Over
    If hunger reaches 10, happiness reaches 0, or energy drops to 0 — the pet dies.

🧩 Game Logic Summary

After every action (even skipping), the pet ages and stats decay:

The game ends if:


đŸ–ŧī¸ Screenshot

Tamagotchi GUI Screenshot Tamagotchi GUI Screenshot

✨ Highlights

📁 File Info

📌 What I Learned

đŸ› ī¸ Future Ideas


👩‍đŸ’ģ Author

Sanskriti – Java enthusiast & beginner developer learning through building ✨