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.
- Features
- Architecture
- Prerequisites
- Installation
- Usage
- Game Mechanics
- Project Structure
- Technologies Used
- Testing
- Contributing
- 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
- 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
- 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
The application follows a client-server architecture with clear separation of concerns:
โโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโ
โ Client โโโโโโโโโโบโ Server โโโโโโโโโโบโ AquariumStateโ
โ (Console) โ Socket โ (Handlers) โ Observerโ (Singleton) โ
โโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโ
- 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
- 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
- Java 21 or higher
- Maven 3.6+ for building
- Windows OS (batch scripts provided; adaptable for Linux/Mac)
- Internet connection (for fish facts API)
-
Clone the repository
git clone https://github.com/JKaulback/care-keeper-aquarium.git cd carekeeperaquarium -
Build the project
build.bat
Or using Maven directly:
mvn clean package
-
Verify the build
- The JAR file will be created at:
target/carekeeperaquarium-1.0-SNAPSHOT.jar
- The JAR file will be created at:
Run the server first (only one server instance needed):
server.batOr manually:
java -jar target/carekeeperaquarium-1.0-SNAPSHOT.jarThe server will start on port 8080 and wait for client connections.
Open a new terminal and run:
client.batOr manually:
java -jar target/carekeeperaquarium-1.0-SNAPSHOT.jar clientMultiple clients can connect simultaneously!
Run both server and client at once:
.\server; .\client- Enter a unique username (alphanumeric, spaces, hyphens, underscores allowed)
- Username must not already be in use
- Add Fish - Randomly generate a new fish to your collection
- View Your Fish - See all your fish with their health status
- Feed Your Fish - Feed all your living fish to restore health
- Remove Fish - Select and remove a fish from your collection
- Clean Tank - Restore tank cleanliness to maximum
- View Tank - See overall aquarium statistics for all users
- Get Fish Fact - Receive a random, interesting fish fact
- Quit - Disconnect from the server
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
- Tank cleanliness decreases based on fish count and size
- Fish get hungrier
- Fish grow larger
- Users earn points
- All clients receive status updates
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
- Java 21: Primary programming language
- Maven: Build automation and dependency management
- 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
- JsonGPT API: AI-powered fish fact generation
- VS Code: Primary IDE
- Git: Version control
- Windows Batch Scripts: Build and run automation
Run the test suite:
mvn testTests are included for:
AquariumManagerbusiness logicThreadPoolManagerconcurrencyAquariumStatestate managementFishentity behaviorUserProfileuser operations
Test reports are generated in: target/surefire-reports/
mvn clean packagemvn clean package -DskipTestsmvn testmvn cleanThe 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
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
- 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)
This is an educational project for PROG2200 at NSCC.
This project is developed as part of an academic assignment.
JKaulback
- GitHub: @JKaulback
- Project: care-keeper-aquarium
- 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! ๐ ๐๐ก