arr2D & StdDraw
arr2D & StdDraw

Today everyone working gloriously alone.

Required Working Style for Today's Lab:

  • From beginning to end you will work in a folder which contains all your work for today's lab.

  • Before you leave, you will email me all the files necessary to run your application.
  1. Review of This Morning

    Implement the spokedWheel & bikeTire methods of this morning's class & write the appropriate main to take advantage of them.

    Let user decide which they want, the 4 spoked circles we started with or the 4x4 we ended with of bicycle tires.

  2. Arrays & If-stmt(s)

    Make your scale 0,30 for x & y

    Given(ie,scanner) a ragged array of doubles, write a program which responds in the following way to each row.

    • If a row has exactly 3 elements use them as x,y,r to create a circle or square. Every time the circle or square should be determined randomly by your program.

    • If a row has at least 4 elements and all are positive, use them to create an ellipse as x,y,r1,r2

    • If a row has at least 4 elements and the first 2 are positive while the next two have different signs, use them to as x1,y1,x2,y2 to create a line after first taking the absolute value of any which are negative.

    • If a row has at least 4 elements and the first 2 are positive and the next two have the same sign as each other (both negative or both positive) use them as x,y,r1,r2 to create rectangle after making sure all are positive

    • Otherwise ignore the row and go on to the next row until all rows have been dealt with.

    Notice there is some OVERLAP in the conditions for "at least 4" when all values are positive. In that case your code should DO BOTH. To handle the confusion, set each shape to a different semi-transparent color so that both are visible *AND* they should both be filled with a fully opaque outline.

    Last week a few of you got to this section, and as I did not specify, you CHOSE one of the following file formats.

    MethodDescriptionExample File
    FORMAT A
    
      #rows
      #cols1 #cols2 #cols3 ..... (exactly #rows of them!)
    
      then all the individual row array values as doubles
    
    
    
    A.txt
    FORMAT B
    
      #rows
      #cols1  then #cols1 individual row array values as doubles
      #cols2  then #cols2 individual row array values as doubles
      #cols3  then #cols3 individual row array values as doubles
      . 
      . 
      . for #rows of them 
    
    
    
    B.txt

    Notice there is some OVERLAP in the conditions for "at least 4" when all values are positive. For those who chose one way last time, I want you to SWITCH and modify your code accordingly this time. For those attempting this exercise for the first time, you may CHOOSE either.

    All CLIENTS should include either MethodA or MethodB as part of the class name.

  3. Re-Write

    Once you have the above working... transparent colors & appropriate file format, Re-WRITE your code using a SEPARATE STATIC METHOD for each condition. Your submission for today should include BOTH versions -- without the extra methods and with the extra methods. Each with a different name though correctly indicating the file format used and both compiling.

  4. Polar Equations....and arrays
    (Every shape should be drawn by a static method call from an if-statement in main)

      1. First, Make a menu of possibilities. Here's one I made

        MenuClient.class

      2. Second, 1.5.21   polar equation curves
        Start from the provided code which .... plots a circle.

        A circle can be described using a polar equation.

        r = 1

        This starter set of code plot's that simple equation. Notice how x & y are computed in the loop.

        UnitCircleClient.java

        (LabeledUnitClient.class)

        1.5.21 suggests some more interesting equations. Try them...

      3. Next, for each of the shapes (in their separate methods), try placing the calculated Euclidean coordinates into two array's x & y and plotting as a single filled & single framed polygon (MenuPolyClient.class).