Fish Lab
Fish Lab

Assigned partners for today are...
  • Olivia  , working gloriously alone!
  • Libby and Mary
  • Jessie and Nevena
  • Ethan and Noah
  • Haley and Nicole
  • Blake and Valentino
  • Mustafa and Michaela
  • Robert (Remote), working gloriously alone!
  • Izzy (Remote), working gloriously alone!

Partner names to the left type first. Your team will work only on this person's account today. I will tell you when to switch to the second partner typing. The second partner should not be logged into any machine today.

Machines are ASSIGNED as well. The goal is to work exclusively with your new partner.

If your partner is not here, login into assigned machine and begin working alone.


OVERVIEW

 Time to write a Fish class.

  • a client class is given to you ClientFish.java
  • a "service" class with the appropriate "servicing" methods of a Fish.
You will be creating the behavior you are testing.....

Here's how ClientFish.java works with a fish my fish...
  download 1) ClientFish.java, 2) Fish_LD.class, and 3) drDaleFish.txt

javac ClientFish.java
java ClientFish < drDaleFish.txt

You'll create YOUR fish class, modify the initials in ClientFish.java and use it as you work on your fabulous fish design.

  1. Create a class called Fish_AB which controls the drawing of a fish.

    Replace A with the first initial of your group's first driver and B with the first initial of your second driver. For example, Mustafa & Michaela will name their fish class Fish_MM.java If you don't have an assigned partner today or your partner is absent, then congratulations! You are working gloriously alone. Use your own first and last initials to name your fish. For example, "Olivia Rhodes" will name her fish class Fish_OR.java

    Your drawing should be more than a circle but less than a detailed drawing complete with scales. You can go back after you complete part II and make the fish more elaborate. For part I, I'm happy if it just has at least 3 non-trivial body parts, has at least 2 different kinds of shapes, and is clearly different in appearance from that of any other lab group. Be sure that at least one larger part is a filled shape. After the first 15 minutes or so of lab, a Fish & the provided client should always compile and have the following:

    • A simple constructor which accepts exactly four parameters
      1. the x and
      2. the y of the imaginary boundaries of the fish's drawing
      3. width
      4. height of this same temporary design area in that order!

    NOTE0:
    **ALL** parts should fit within IMAGINARY rectangle defined by these values you should go ahead and draw a red rectangle using them and keep it around as you DESIGN your fish and get the parts where you want them. However, when you are done you should remove all reference and drawing of this rectangle!!!!

    NOTE1: these are not the "usual" for drawing a rectangle:
            x,y is upper left corner
            w is FULL SIDE length
            h is FULL SIDE length
    This make the math for the body parts simpler but... slightly complicates the drawing of your rectangle:
            StdDraw.rectangle( x+w/2, y-h/2, w/2, h/2 );

    NOTE2: your constructor should assign all instance variables and as the very last thing call a draw method which you must also write that actually makes the drawing calls to StdDraw

    NOTE3: all mutating methods should inclde a call to draw as the last thing so your beautiful work shows!!!

  2. Add the following methods to your Fish class and test for ALL OF THEM in ANOTHER CLIENT OF YOUR OWN DEVISING. That is, your FishyClient will include something that calls all of the methods somehow in a way which is clear to the user and easily repeated in such a way that the user knows something happened because of what they've done.
      Mutating Method
    • translate
    • setColor

    Test & retest your modified fish with your new FishyClient! Add the following methods to your Fish class and test for ALL OF THEM in your ANOTHER CLIENT OF YOUR OWN DEVISING. That is, your FishyClient will include something that calls all of the methods somehow in a way which is clear to the user and easily repeated in such a way that the user knows something happened because of what they've done.

      Accessor Methods
    • getX                 X & Y should be upper left corner of all parts of fish
    • getY

    • getWidth       should be the entire width of all body parts
    • getHeight      ditto for height

    Test & retest your modified fish with your new FishyClient!

    How should you go about testing accessor methods??? As follows:

    Write a test client with the exact press method given. The method should be EXACTLY AS WRITTEN (except for replacing AB with the proper letters for YOUR fish):

                Generate a random x, y, w, & h that will still be visible in your window at chosen scale.
                
                  draw a rectangle there.
    
                  now construct a fish using those exact same randomly chosen parameters.
    
                }

    Randomness belongs in Clients for your Fish class; not in the Fish themselves.

    If the resulting fish are not exactly and completely inscribed by the resulting framed rectangle, one or more of your accessor methods is not working correctly. In some cases, the problem(s) may also go back to your constructor; the x & y value provided to the constructor should be the upper left point of the bounding box shrinkwrapping your fish and all it's fishy parts! Not sure what I mean by "shrinkwrap"? Or "exactly and completely inscribed"?

    See examples from previous years...here

    Use a TEMPORARY framed rectangle in your hardest working constructor and make sure all the parts are exactly constructed inside it. The frame should be constructed with the exact parameters sent and not modified in any way. It can be helpful to assign the frame to a local variable and set the color to something that contrasts with your fish so you can see when the parts stick out or don't fill up the frame.

    When your fish and all it's fishy bits fit exactly inside the frame, then you should delete this TEMPORARY frame because it has done it's job. Fish perfection, (-:

    Mail me your Fish_AB.java source code only.