Project #3: Aquarium

Project Due: 0930 EDT on 30 Apr 2020

  Executive Summary

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.

Examples

(Note: Your GUI isn't expected to look exactly like either of these.)




Downloadable & Runnable Example

Click here to download an example .jar file that you can run with the following:

java -jar Aquarium.jar
or

java -jar Aquarium.jar <your_own_background_image_file>

Honor

The course policy and the instructions it references, most pertinently COMPSCIDEPTINST 1531.1D, spell out what kinds of assistance are permissible for programming projects. The instructor can give explicit permission for things that would otherwise not be allowed. For this project, you have explicit permission
  1. to get help from any Spring 2019 IC211 instructors (any assistance must be documented though), and
  2. to use general purpose Java resources online (though such use must be documented). Resources that might specifically address this project, like the code for programs that simulate moving objects, are not allowed.
Put together the instructions referenced in the course policy and the explicit permissions above, and what you get is summarized as:
  • The only help you may receive on a project is from your instructor or the other IC211 instructors, and that help must be clearly cited. In turn, you cannot provide help to any IC211 students on this project.
  • Under no circumstance may you copy code and submit it as your own work. That is the definition of plagiarism.
  • You may not look at other people's project code, nor may you show your own code to others.
  • You can look at online resources for general purpose Java programming, but not for help writing anything that is specific to the functionality required of your project.

Part 1 (20 pts) - Creating life

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)

Part 2 (15 pts) - Eating and Dying of Hunger

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.

Part 3 (20 pts) - Basic Control Panel

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.

Part 4 (20 pts) - Run/Pause & Select

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.

Part 5 (15 pts) - Advance Controls

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.

Part 6 (10 pts) - README

Include in your submission a README file that includes the following:

Part 7 (1 to 15 pts) - Extra Credit

Amount of points earned depends on functionality, implementation, and difficulty.

Consider these ideas, but remember creativity is encouraged! Be creative!

How to submit

~/bin/submit -c=IC211 -p=project03 *.java *.bmp *.jpg *.jpeg *.png README

How projects are graded / how to maximize your points

Things to keep in mind to receive full marks:
  1. Submit all required items (as described above) on time.
  2. Do not submit any .java files that do not compile!
  3. Use good object-oriented design! The means adhering to the principles of encapsulation, data/information hiding, making good use of inheritance and polymorphism.
  4. Document all of your code, and use javadoc syntax.
  5. Practice good Java Style. This means proper indentation, use of whitespace within lines of code, logical organization of chunks of code, proper naming of classes, methods, fields, and constants in accordance with Java conventions.