Project 3: All I see is fish | CS 2113 Software Engineering - Spring 2021

Project 3: All I see is fish #

In this project, you’re on your own — no starter code! This is your baby (or fish?) to nurture and build up from scratch. The goal of this project is to design a Fishtank simulation with a GUI that has local and remote control capabilities (over the network).

As this is a relatively large and (potentially) complex project that is assigned at a high stress time of the semester, you have TWO options for completing it for a grade.

  1. You can complete an implementation for the project, and potentially earn up to 150/100 points (yes, that additional 50 points would be bonus).

  2. You can complete a full design document that outlines how you would develop this project, that is detailed enough that your vision for an implementation is clear. You could earn 75/100, and as long as you meet the min requirements, you are guaranteed to get that grade (see info below).

The choice is yours for which direction you want to take.

Preliminaries #

Github Classroom Link: https://classroom.github.com/a/9H-jGKaQ

Testing/Grading #

There is no test scripts. You will be grading based on functionality and OOP design.

Compiling your code #

Your code should compile with javac, like

javac *.java

Development Environment #

You can partially complete this code using replit, but in order to complete the networking part, you will need to do some local development either using the command line, IntelliJ, VisualStudio, or Xcode


The Fish Tank #

The goal of this project is to develop a fish tank simulation that uses java GUIs, graphics, threads, and sockets. The core idea for the fish tank simulator can be viewed in the following screenshot.

Grafiti Button

The basic idea is that you will have fish swimming around (as images) potentially each other and also eating plankton (the green dots). You can control when fish are fed (adding plankton to the tank) as well as when you add new fish. Fish swim in different ways and interact with other fish. There are additional controls to change the speed of the fish. You can also control when the tank simulation starts and stops with GUI controls, and these commands can also be sent over the command line (see terminal below). If you complete this project fully, you’ll also be able to remotely control the fishtank over the network with a separate GUI connecting to the fish tank via sockets.

As you design and/or build your fish tank, it is important that you use good OOP design that takes advantage of encapsulation, inheritance, and polymorphous. If you are not using good OOP, you’ll find this project much more difficult than it needs to be.

There is a lot of room for creativity in this project. Your fish can be different than mine. This is only an outline, but it is entirely up to you what you want your fish tank to look like and the behavior of your fish.

Implementation Based Submission Requirement (up to 150/100 points) #

In your development, you can reach a certain grade by completing a given level. You should not submit non-working code at a level, as it is difficult to grade. Instead you should designate which level you reached in your README file and submit that code.

Level 0: Life (up to 75 points) #

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. (You can choose those values!)

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);

Notes on good OOP: You should probably consider inheritance for handling the various fish in the simulation, like we did in Project 2.

Level 1: Death (up to 85 points) #

Add functionality such that fish eat plankton and 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.)

Here’s a tip, look at the Rectangle class for methods you could use.

Level 2: User Control (up to 95 points) #

You should create a GUI control panel to control the actions in the take and communicate information:

Design Note 1: You probably need an additional identifier for each fish, other than the type of fish, ie. it’s a shark or a salmon. For example it could be Shark 2 or Shark a, this way the user can specific which shark (if there are two or more) it wishes to change/retrieve a feature of

Design Note 2: How your GUI controls look and which dialog you use, such as text boxes, buttons, combo boxes, etc., is entirely up to you. Do what makes the most sense.

Design Note 3: We’re not grading with respect to how good or fancy your GUI looks, but it should be functional in an obvious way. The buttons should be clearly labeled and the resulting actions should be intuitive.

Level 3: A new kind of fish (up to 100 Points) #

Get creative by adding at least two of the following features:

Design Note 4: Whatever you choose is entirely up to you. Be creative, but your new design feature should be clearly evident in the simulation and describable.

Design Note 5: Be sure to describe your new behaviors in the README

Level 4: Command Line interface (up to 120 Points) #

Note that each of the controls in Level 2 are fairly well defined, and while using them in a GUI is surely convenient, you could imagine instead a simple command line interface to issue commands. For example:

Enter Command: LIST
shark 1
goldfish 1
goldfish 2
salmon 1
Enter Command: START
SUCCESS
Enter Command: ADD goldfish
SUCCESS
Enter Command: FEED
SUCCESS
Enter Command: GET goldfish 3 hunger
goldfish 3 hunger is 10
Enter Command: SET shark 1 speed 120
shark 1 speed is now 120
Enter Command: STOP
SUCCESS
Enter Command: RESET
SUCCESS
Enter Command: GET goldfish 4 hunger
ERROR unknown goldfish 4

In this level, you should implement a command line interface whereby your fishtank simulation reads input from the console, parses that input, and takes appropriate actions as a result within the simulation. You should at least implement the following commands

Design Note 6: If you use good OOP design on this level, the next level will be surprisingly easy.

Level 5: Client/Server (up to 140 Points) #

Next level, instead of reading the commands only from the command lines, command can also be issued over the network. To do this you’ll need to:

  1. Add a GUI element to your fishtank to specify the ip-address/hostname to listen for incoming connections on a socket.

  2. Once a client connects, the server listens for commands using the same format as in Level 4.

  3. The fishtank server should respond with SUCCESS and ERROR to the client.

Design Note 7: You can use netcat to connect to your server and type commands.

Importantly, your Fishtank should also use the command line and the network socket to recieve commands. This will require multi-threading!

Design Note 8: Consider have a thread for the command line and a thread for a client. Be careful about concurrency because there is also the GUI thread!

Design Note 9: Yes, you should be able to support multiple client connections.

Level 6: GUI Client (up to 150 Points) #

Finally, the last level! Create another GUI for the client which provides an option to connect to the fishtank server at a specified port. When the user uses the GUI it sends the same information over socket, and displays the response from the server.

Implementation Submission Requirements #

To submit an implementation solution you should provide the following information

  • In the README.md file, indicate which level you achieved.
  • In the README.md file, describe the additional features you added as a part of Level 2 and Level 3.
  • You can submit any number of java files, but your code should be able to compile via:
    javac *.java
    
  • To run your fishtank simulation it should be done like
    java Fishtank
    
  • To run a remote client GUI
    java RemoteGUI
    

ONLY submit code up to a level that is fully complete.

Also DON’T FORGET TO ALSO SUBMIT YOUR IMAGE FILES!!!! Otherwise, we can’t run your fish tank,

Design Based Submission Requirements (up to 75/100 points) #

If you want to opt for a design submission, you must complete a full design document that describes a Level 3 solution. Your design document must include:

  1. At least a one page (4-5 paragraph) narrative of your design and the interaction between the associated classes. This should refer to specific details of the classes, including their members and methods. You can also include images to help convey your point.

  2. A UML diagram describing the relationships between the classes. This should include inheritance relationships and also implements, depends, and contains.

  3. A full description of each class that would be required. This includes the private/public members and methods. Use the Java Docs as a guide, where there is a brief description at the top followed by other details.

  4. A One page (3-4 paragraph) description of how your design leverages OOP. Be sure to note how your design leverages encapsulation, inheritance, and polymorphism.

You should submit your design document as design.pdf in the git repo. In your README clearly indicate you are submitting a design based solution.

No! You cannot submit your design document in other format. Yes! It must be a PDF and only a PDF.