How pragalvhasharma/cs-2212-group-project works
Project Type & Purpose
• The project is a desktop simulation game (inspired by Tamagotchi-style experiences) where the user cares for a virtual pet. It is built using Java Swing for the user interface, with a strong object-oriented design.
• The primary purpose is to manage the pet’s states (such as hunger, mood, and health) through interactive UI panels and game logic, supported by features like save/load game, parental controls, and an emergency food rescue mechanic.
Breaking Down the File Structure
• Main Source Code (src/main/java/com/group14/virtualpet):
– The project’s entry point is in Main.java and MainFrame.java, which likely initialize the application and main user interface.
– The model package contains key classes (Pet, Inventory, FoodItem, GiftItem, Item, PetState) that define the game’s domain data and behavior.
– The state package holds classes like GameState, which probably manage the current state of the game (e.g., when the pet is hungry, angry, or sleeping).
• UI Package (src/main/java/com/group14/virtualpet/ui & its subfolder gameplayPanelComponents):
– Divides the UI into multiple panels (MainMenuPanel, GameplayPanel, InstructionPanel, SettingsPanel, ParentalControlsPanel, PetSelectionPanel) to handle different functionalities.
– The gameplayPanelComponents break down the gameplay panel into sub-components (CommandPanel, InventoryPanel, PetInfoPanel, PetSpritePanel, RoundedPanel) for a modular design.
• Utilities & Resources:
– The util package includes AudioManager (likely for playing sounds) and SaveLoadUtil (for persisting game states).
– The resources folders include images (for pet sprites) and sounds used in-game.
• Testing (src/test):
– Contains tests (e.g., SaveGameTest, ResourceTest) that validate resource loading and game state persistence.
a. Main Components:
• Application Entry & Main Window:
• Main.java and MainFrame.java as the starting point.
• Game Model Layer:
• Domain classes (Pet, Inventory, FoodItem, GiftItem, PetState, etc.) representing the pet’s attributes and overall game data.
• UI Layer:
• Panels for different functionalities: MainMenu, Gameplay, Instructions, Pet Selection, Settings, and Parental Controls.
• Inside the Gameplay panel, include sub-components (CommandPanel, PetInfoPanel, InventoryPanel, PetSpritePanel, RoundedPanel) that structure user interactions.
• State Management:
• GameState class managing the game’s current state and transitions (Normal, Hungry, Angry, Sleeping, Dead).
• Utility Components:
• AudioManager to manage audio cues.
• SaveLoadUtil to persist and restore game states.
• Resource Layer:
• External assets (images, sounds) loaded from the resources folders.
b. Relationships & Interactions:
• The UI layer will interact with the Game Model Layer through controller-like interactions or direct method calls to update pet stats based on user actions.
• The GameState component will trigger UI updates (like switching panels or displaying alerts) when state transitions occur.
• Utility components (AudioManager, SaveLoadUtil) serve as supporting services invoked by both the UI and model layers. For example, SaveLoadUtil is called when the user saves or loads the game, while AudioManager is triggered by user interactions or game events.
• Resources are accessed by the respective components (e.g., pet images loaded into SpritePanels).
c. Architectural Patterns & Design Principles:
• The design follows object-oriented principles, with a clear separation of concerns (domain/model vs. UI vs. utility services).
• A quasi-MVC/MVP style pattern can be visualized, where:
• The Model represents the game data (Pet, Inventory, etc.).
• The View consists of multiple UI panels built with Java Swing.
• The Controller is implied in the way UI components forward user interactions to update the model or state.
• Modular design is evident in the distinct packages and sub-components that encapsulate specific features (e.g., ParentalControlsPanel, SaveLoadUtil).
d. Relevant Technologies & Frameworks:
• Java 21 and Java Swing for the graphical interface.
• Maven for build automation (note the presence of pom.xml).
• Unit tests structured in JUnit (in the src/test folder).
Final Advice
• Be explicit about interactions – for example, show how an action in the GameplayPanel triggers state evaluation in GameState, and how inventory updates may lead to an emergency ration from the Emergency Food Rescue System.
• Maintain clarity with legends or notes if needed, given the number of panels and states.