Skip to content

Latest commit

ย 

History

39 Commits

Folders and files

NameName
Last commit message
Last commit date
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

CareKeeper Aquarium ๐Ÿ 

A multi-user, client-server aquarium simulation game where users can manage their virtual fish, maintain tank cleanliness, and learn interesting fish facts through an interactive terminal interface.

๐Ÿ“‹ Table of Contents

โœจ Features

Core Gameplay

  • Multi-User Support: Multiple users can connect simultaneously and manage their own fish
  • Virtual Fish Management: Add, view, remove, and feed your fish
  • Real-Time Updates: Aquarium state updates automatically displayed to all connected clients
  • Tank Maintenance: Monitor and clean tank cleanliness
  • Fish Lifecycle: Fish grow, get hungry, and can die if not properly cared for
  • Point System: Earn points for maintaining your fish

Interactive Features

  • Random Fish Facts: Get interesting and varied fish facts from an AI-powered API
  • Live Status Display: Real-time aquarium status header showing tank cleanliness, users online, and your fish
  • Intuitive Menu System: Arrow-key navigation menus powered by JLine
  • Text Wrapping: Automatic text wrapping for better readability

Technical Features

  • Observer Pattern: Real-time state synchronization across all clients
  • Thread Pool Management: Efficient handling of multiple client connections
  • Scheduled Tasks: Automatic tank updates every minute
  • Graceful Shutdown: Proper resource cleanup and user session management

๐Ÿ—๏ธ Architecture

The application follows a client-server architecture with clear separation of concerns:

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”         โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”         โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚   Client    โ”‚โ—„โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–บโ”‚   Server    โ”‚โ—„โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–บโ”‚ AquariumStateโ”‚
โ”‚  (Console)  โ”‚  Socket โ”‚ (Handlers)  โ”‚ Observerโ”‚  (Singleton) โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜         โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜         โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Key Components

  • Client Layer: Terminal UI with JLine for interactive menus and real-time updates
  • Server Layer: Multi-threaded server handling concurrent client connections
  • Business Layer: Game logic, fish factory, and thread pool management
  • Model Layer: Domain entities (Fish, UserProfile, AquariumState)
  • Integration Layer: External API integration for fish facts

Design Patterns

  • Singleton Pattern: AquariumState ensures single shared state
  • Observer Pattern: StateObserver notifies all clients of state changes
  • Factory Pattern: FishFactory creates randomized fish instances
  • Command Pattern: Enum-based command system for client-server communication

๐Ÿ”ง Prerequisites

  • Java 21 or higher
  • Maven 3.6+ for building
  • Windows OS (batch scripts provided; adaptable for Linux/Mac)
  • Internet connection (for fish facts API)

๐Ÿ“ฆ Installation

  1. Clone the repository

    git clone https://github.com/JKaulback/care-keeper-aquarium.git
    cd carekeeperaquarium
  2. Build the project

    build.bat

    Or using Maven directly:

    mvn clean package
  3. Verify the build

    • The JAR file will be created at: target/carekeeperaquarium-1.0-SNAPSHOT.jar

๐Ÿš€ Usage

Starting the Server

Run the server first (only one server instance needed):

server.bat

Or manually:

java -jar target/carekeeperaquarium-1.0-SNAPSHOT.jar

The server will start on port 8080 and wait for client connections.

Starting the Client

Open a new terminal and run:

client.bat

Or manually:

java -jar target/carekeeperaquarium-1.0-SNAPSHOT.jar client

Multiple clients can connect simultaneously!

Quick Start Script

Run both server and client at once:

.\server; .\client

๐ŸŽฎ Game Mechanics

Login

  • Enter a unique username (alphanumeric, spaces, hyphens, underscores allowed)
  • Username must not already be in use

Menu Options

  1. Add Fish - Randomly generate a new fish to your collection
  2. View Your Fish - See all your fish with their health status
  3. Feed Your Fish - Feed all your living fish to restore health
  4. Remove Fish - Select and remove a fish from your collection
  5. Clean Tank - Restore tank cleanliness to maximum
  6. View Tank - See overall aquarium statistics for all users
  7. Get Fish Fact - Receive a random, interesting fish fact
  8. Quit - Disconnect from the server

Fish Characteristics

Each fish has:

  • Species: 12 different types (Clownfish, Betta, Angel Fish, etc.)
  • Health: Current health / Maximum health
  • Size: Small, Medium, or Large
  • Age: Tracked in days
  • Hunger Level: Affects health over time

Automatic Events (Every Minute)

  • Tank cleanliness decreases based on fish count and size
  • Fish get hungrier
  • Fish grow larger
  • Users earn points
  • All clients receive status updates

๐Ÿ“ Project Structure

carekeeperaquarium/
โ”œโ”€โ”€ src/
โ”‚   โ”œโ”€โ”€ main/
โ”‚   โ”‚   โ””โ”€โ”€ java/
โ”‚   โ”‚       โ””โ”€โ”€ com/
โ”‚   โ”‚           โ””โ”€โ”€ carekeeperaquarium/
โ”‚   โ”‚               โ”œโ”€โ”€ Main.java                    # Application entry point
โ”‚   โ”‚               โ”œโ”€โ”€ business/                    # Business logic layer
โ”‚   โ”‚               โ”‚   โ”œโ”€โ”€ AquariumManager.java     # Main game logic coordinator
โ”‚   โ”‚               โ”‚   โ”œโ”€โ”€ FishFactory.java         # Fish creation factory
โ”‚   โ”‚               โ”‚   โ””โ”€โ”€ ThreadPoolManager.java   # Concurrent execution
โ”‚   โ”‚               โ”œโ”€โ”€ client/                      # Client-side components
โ”‚   โ”‚               โ”‚   โ”œโ”€โ”€ AquariumClient.java      # Client networking
โ”‚   โ”‚               โ”‚   โ”œโ”€โ”€ ConsoleUI.java           # Terminal UI wrapper
โ”‚   โ”‚               โ”‚   โ”œโ”€โ”€ Menu.java                # Menu data structure
โ”‚   โ”‚               โ”‚   โ””โ”€โ”€ MenuHandler.java         # Menu logic
โ”‚   โ”‚               โ”œโ”€โ”€ common/                      # Shared components
โ”‚   โ”‚               โ”‚   โ””โ”€โ”€ Command.java             # Command protocol
โ”‚   โ”‚               โ”œโ”€โ”€ integration/                 # External integrations
โ”‚   โ”‚               โ”‚   โ””โ”€โ”€ FishFactAPI.java         # Fish facts API client
โ”‚   โ”‚               โ”œโ”€โ”€ model/                       # Domain models
โ”‚   โ”‚               โ”‚   โ”œโ”€โ”€ AquariumState.java       # Global state (Singleton)
โ”‚   โ”‚               โ”‚   โ”œโ”€โ”€ Fish.java                # Fish entity
โ”‚   โ”‚               โ”‚   โ””โ”€โ”€ UserProfile.java         # User entity
โ”‚   โ”‚               โ””โ”€โ”€ server/                      # Server-side components
โ”‚   โ”‚                   โ”œโ”€โ”€ AquariumServer.java      # Server socket manager
โ”‚   โ”‚                   โ”œโ”€โ”€ ClientHandler.java       # Per-client handler
โ”‚   โ”‚                   โ””โ”€โ”€ StateObserver.java       # Observer pattern impl
โ”‚   โ””โ”€โ”€ test/
โ”‚       โ””โ”€โ”€ java/
โ”‚           โ””โ”€โ”€ com/
โ”‚               โ””โ”€โ”€ carekeeperaquarium/
โ”‚                   โ”œโ”€โ”€ business/                    # Business layer tests
โ”‚                   โ””โ”€โ”€ model/                       # Model layer tests
โ”œโ”€โ”€ pom.xml                                          # Maven configuration
โ”œโ”€โ”€ build.bat                                        # Build script
โ”œโ”€โ”€ server.bat                                       # Server launcher
โ”œโ”€โ”€ client.bat                                       # Client launcher
โ””โ”€โ”€ README.md                                        # This file

๐Ÿ› ๏ธ Technologies Used

Core Technologies

  • Java 21: Primary programming language
  • Maven: Build automation and dependency management

Libraries & Frameworks

  • JLine 3.21.0: Rich terminal UI with ANSI support, arrow-key navigation
  • Gson 2.10.1: JSON parsing for API responses
  • JNA 5.13.0: Native library access for terminal control
  • JUnit Jupiter 5.9.3: Unit testing framework

APIs

  • JsonGPT API: AI-powered fish fact generation

Development Tools

  • VS Code: Primary IDE
  • Git: Version control
  • Windows Batch Scripts: Build and run automation

๐Ÿงช Testing

Run the test suite:

mvn test

Test Coverage

Tests are included for:

  • AquariumManager business logic
  • ThreadPoolManager concurrency
  • AquariumState state management
  • Fish entity behavior
  • UserProfile user operations

Test reports are generated in: target/surefire-reports/

๐Ÿ—๏ธ Building from Source

Full Build

mvn clean package

Skip Tests

mvn clean package -DskipTests

Run Tests Only

mvn test

Clean Build Artifacts

mvn clean

๐Ÿ”Œ API Integration

The application integrates with the JsonGPT API for fish facts:

  • Endpoint: https://api.jsongpt.com/json
  • Prompt Engineering: Uses 90+ unique prompt combinations for variety
  • Error Handling: Graceful fallbacks for API failures
  • Timeout: 10-second connection timeout

๐ŸŽฏ Future Enhancements

Potential features for future versions:

  • Fish breeding system
  • Rare/legendary fish species
  • User achievements and leaderboards
  • Save/load game state to database
  • Web-based client interface
  • Fish trading between users
  • Customizable aquarium themes

๐Ÿ“ Known Issues

  • API occasionally returns error codes (handled gracefully)
  • Terminal ANSI codes may not work on all terminal emulators
  • Windows-specific batch scripts (Linux/Mac users need shell scripts)

๐Ÿ‘ฅ Contributing

This is an educational project for PROG2200 at NSCC.

๐Ÿ“„ License

This project is developed as part of an academic assignment.

๐Ÿ‘จโ€๐Ÿ’ป Author

JKaulback

๐Ÿ™ Acknowledgments

  • NSCC PROG2200 instructors and course materials
  • JsonGPT API for fish fact generation
  • JLine library for terminal UI capabilities
  • Open source community for inspiration and resources

Happy Fish Keeping! ๐Ÿ ๐ŸŸ๐Ÿก

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages