An object-oriented Python aquarium simulation featuring four types of animals: two fish types (Scalar and Moly) and two crab types (Ocypode and Shrimp).
- Add animals with customizable attributes (name, age, location, direction)
- Simulate animal movement in a 2D aquarium environment
- Feed all animals at once
- Step through the simulation turn-by-turn or multiple steps at a time
- Print a live board display of the aquarium state
- Demo mode showcasing the functionality with predefined animals
- Python 3.x installed on your system
Clone the repository and run the main program:
git clone https://github.com/kamberasaf/The-OOP-aquarium.git
cd The-OOP-aquarium
python main.py- When prompted, enter the aquarium dimensions (width >= 40, height >= 25)
- Use the main menu to add animals, feed them, advance simulation steps, or run the demo
- Follow input instructions carefully for adding animals (name, age, position, direction)
Welcome to "The OOP Aquarium"
The width of the aquarium (Minimum 40): 50
The height of the aquarium (Minimum 25): 30
Main menu
------------------------------
1. Add an animal
2. Drop food into the aquarium
3. Take a step forward
4. Take several steps
5. Demo
6. Print all
7. Exit
What do you want to do? 5
Tests are located in the tests/ directory and use pytest. To run the tests:
pip install pytest
pytest tests/python main.pyfrom Aqua import Aqua
aq = Aqua(50,25)
aq.add_animal("scalarfish1", 4, 10, 10, 1, 0, 'sc')
aq.add_animal("molyfish2", 12, 35, 15, 0, 1, 'mo')
aq.add_animal("shrimpcrab1", 3, 20, aq.aqua_height, 1, 0, 'sh')
aq.add_animal("ocypodcrab1", 13, 41, aq.aqua_height, 0, 0, 'oc')
for _ in range(3):
aq.print_board()
aq.next_turn()Run the unit tests with pytest:
pytest tests/