To showcase your OOP design principles, you are writing an Aquarium GUI that simulates the life cycles of at least four species of animals: phytoplankton, two types of fish, and sharks. The fish and sharks must eat to survive and die if they aren't fed in a specified time. Fish eat plankton. Sharks eat fish.
Throughout the simulation, you're required to display information about the fish population and give the user the option to feed the fish (add plankton) or add new fish and sharks.
This project is designed to exercise your ability to write good Object-Oriented code in Java, which will include good use of encapsulation, data-hiding, inheritance, polymorphism, class hierarchies, interfaces, and exception handling. Ensure you spend enough time designing your classes to make adding new features easy! Time spent up front can save you a lot of time later!
Last, be creative! This project has a lot of room for creativity! (and extra credit for exceptional features) For full credit, your project must meet the requirements laid out in Parts 1-5.
(Note: Your GUI isn't expected to look exactly like either of these.)
Click here to download an example .jar file that you can run with the following:
java -jar Aquarium.jaror
java -jar Aquarium.jar <your_own_background_image_file>
Your first step is to create plankton/fish/sharks that swim around an aquarium. Your simulation should start with an appropriate number of plankton/fish/sharks based on their size and the relative size of your aquarium.
To help, here's code that will mirror your image where "img" is a BufferedImage object:
AffineTransform tx = AffineTransform.getScaleInstance(-1, 1);
tx.translate(-img.getWidth(), 0);
AffineTransformOp op = new AffineTransformOp(tx, AffineTransformOp.TYPE_NEAREST_NEIGHBOR);
img = op.filter(img, null);
Alternately, if you provide negative values for width or height in the below drawImage method, then the image will be flipped along the vertical or horizontal axis, respectively.
g.drawImage(img, x, y, width, height, null)
Fish eat plankton. Sharks eat fish. Whenever eating occurs, health goes up. Add this functionality when fish “intersect” plankton, and shark “intersect” fish.
As time goes on, health slowly decreases. The higher the metabolism of a fish, the faster its health decreases, therefore a fish/shark with a higher metabolism must eat more often to stay alive. Fish and sharks die when their health reaches zero. (The metabolism of a fish can be fixed initially, but is chosen by the user on the control panel as described in Part 5 below.)
Code Help: Look at the Rectangle class for methods you could use.
Create a control panel or an additional window that allows the user to create additional sharks/fish/plankton.
Keep in mind, your project’s GUI doesn’t need to look exactly like this example. Add the components (Buttons, ComboBoxes, Sliders, TextFields) necessary to meet the requirements.
Add a start/pause button to your control panel. When paused, the fish should stop moving. When start is clicked, the fish could continue from their current position. Adding fish/plankton while paused should cause the fish to appear in the tank but not move.
When the simulation is paused (at a minimum), clicking on a shark or fish reveal its stats on the control panel. Speed and health must be displayed as well as a third property of your choice.
Code Help: Look again at the Rectangle class. You’ll want to check if the image’s rectangle “contains” the point where the mouse clicked.
Add to your control panel a way for the user to edit settings of the simulation. At a minimum, the user should be able to change the metabolism and speed of fish/sharks. Changes are expected to happen to the entire population of the species, not individual fish/sharks.
Keep in mind, your project’s GUI doesn’t need to look exactly like this example. Add the components (Buttons, ComboBoxes, Sliders, TextFields) necessary to meet the requirements.
Include in your submission a README file that includes the following:
Amount of points earned depends on functionality, implementation, and difficulty.
Consider these ideas, but remember creativity is encouraged! Be creative!
~/bin/submit -c=IC211 -p=project03 *.java *.bmp *.jpg *.jpeg *.png README