Project #3: Aquarium
Project Due: May 1 2019 at 2359
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.
Example: (though your GUI isn't expected to look exactly like this)
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
- to get help from any Spring 2019 IC211 instructors (any assistance must be documented though), and
- 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 (25 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.
- Plankton - When plankton is added with the "Feed" button, it should start at the water's surface, then slowly sink to a random depth and remain there.
- 2 types of fish - A fish should move in a random direction, changing direction at least each time it reaches the boundaries of the Aquarium or the water’s surface. At a minimum, fish must be able to move in the following directions: directly up, down, left or right, or diagonally up-left, up-right, down-left, or down-right. There should be a noticeable difference between how the two fish species move.
For example, a species of fish could:
- swim in a distinct pattern like ovals or sin waves.
- prefer to stay in a particular region of the aquarium.
- Sharks - Sharks will move just like fish.
- The fish and sharks will be represented by appropriate images. Plankton can just be dots. Remember that fish and sharks don't swim backwards!
To help, here's code that will mirror your image where "image" is a BufferedImage object:
AffineTransform tx = AffineTransform.getScaleInstance(-1, 1);
tx.translate(-image.getWidth(), 0);
AffineTransformOp op = new AffineTransformOp(tx, AffineTransformOp.TYPE_NEAREST_NEIGHBOR);
image = op.filter(image, null);
Part 2 (15 pts) - Eating and Dying of Hunger
Fish eat plankton. Sharks eat fish. Add this functionality when fish “intersect” plankton, and shark “intersect” fish.
Fish and sharks die when they haven't eaten anything in a specified amount of time. (The time 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 (25 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
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. When the simulation is paused, clicking on a shark or fish reveal its stats on the control panel. Age and hunger level 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 how long it takes for each species to die of starvation, and how fast they swim.
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 (Extra Credit - up to 15 pts depending on functionality and implementation)
Consider these ideas, but remember creativity is encouraged! Be creative!
- Sharks/fish only eat their prey on overlap given a probability based on how hungry they are.
- Fish that died of hunger float to the top of the tank. Do sharks eat dead fish? Maybe if they are hungry enough!
- Fish produce offspring when a male and female fish overlap.
- Fish get bigger every time it eats.
- Play a sound when a fish dies or gets eaten.
- Add to your panel a live scoreboard with stats about your aquarium. (number of each species, average hunger level, life expectancy)
How to submit
Include in your submission a README file that describes how your solution uses good OOP design. Specifically, you should include the following in your README:
- Describe how your solution uses good OOP design.
- Describe the behavior of your fish/sharks.
- Describe how to use your GUI controls.
- Describe any extra credit you implemented.
- If we cannot figure out how to play your game based on the README, you will not receive credit for those parts.
And then submit everything. Make sure to include your picture files. The following looks for jpg and png extensions, but adapt it to your specific solution:
~/bin/submit -c=IC211 -p=project03 *.java *.jpg *.png README
How projects are graded / how to maximize your points
Things to keep in mind to receive full marks:
-
Submit all required items (as described above) on time.
-
Do not submit any .java files that do not compile!
-
Use good object-oriented design! The means adhering to the principles of encapsulation, data/information hiding, making good use of inheritance and polymorphism.
- Document all of your code, and use javadoc syntax.
-
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.