Securing Higher Grades Costing Your Pocket? Book Your Coursework Help at The Lowest Price Now!

  • +1-617-874-1011 (US)
  • +44-117-230-1145 (UK)
Online Customer Service

Active aquarium Sample Assignment

Write an application that displays an active aquarium with at least 3 fish of different colours swimming back and forth. Each fish should run on its own thread.

Active aquarium

A fish swims left-to-right until it bumps into the right wall, at which time it flips around and heads right-to-left until it bumps the left wall, and so on. Draw each fish at a different water depth (i.e. different y values) and, for simplicity, keep each fish at its constant depth. Have the fish swim at a different speeds (that is, each fish moves forward a slightly different number of pixels than the other fish in each step).

Active aquarium Sample Assignment

A few thoughts on design:

  • You’ll probably want a Fish class to model a fish, an Aquarium class to model the aquarium and driver class.
  • A fish should know its color, position, direction, speed and shape. It may need to know about the aquarium too (e.g. so it knows when it bumps the wall). It should know how to draw itself, flip its direction and so on.
  • Since each fish runs on a thread make sure you do the necessary things to make that happen.
  • Use a polygon to store the fish’s shape (keep your fish simple). Pass the polygon as one of the parameters to the Fish constructor.
  • There are some methods of the Polygon class that may be useful (e.g. translate, intersects, getBounds). There are also some public variables in that class which you might find helpful (xpoints, ypoints, npoints). Check them out in the Java API.
  • Define the initial coordinates for the polygon relative to x = 0. Adjust the x coordinates based on the fish’s new position as the fish swims forward (the translate method may be useful here).
  • For a fish to flip its direction, you’ll also have to modify the x coordinates of each point in the polygon (the getBounds method might be helpful here).
  • Each fish will either need a timer to control the animation (like we had in the bouncing happy face animation) or can use sleep.
  • You may have to play around a bit with fish speeds, timer delay, etc. to get a nice looking animation.
  • To achieve the appearance of movement you need to “undraw” the fish at its current location before drawing it at its new location. To “undraw”, you could simply redraw the fish (or more efficiently, a rectangle encompassing the fish) in the same color as the background. You could also achieve this by repainting and redrawing all fish.
captcha image 


  •   24 x 7 Availability.
  •   Trained and Certified Experts.
  •   Deadline Guaranteed.
  •   Plagiarism Free.
  •   Privacy Guaranteed.
  •   Free download.
  •   Online help for all project.
  • Need Assignment Help


Urgenthomework helped me with finance homework problems and taught math portion of my course as well. Initially, I used a tutor that taught me math course I felt that as if I was not getting the help I needed. With the help of Urgenthomework, I got precisely where I was weak:
Read More

Tap to Chat
Get Instant Assignment Help
Tap to Chat
Get Instant Assignment Help