CSci A201/A597
Frequently Asked Questions on Lab #5


General Questions

  1. Can someone please tell me the available colors in java? I am getting tired of using the same color every time...

    Sure thing. Here they are:

      black        The color black. 
      blue         The color blue. 
      cyan         The color cyan. 
      darkGray     The color dark gray. 
      gray         The color gray. 
      green        The color green. 
      lightGray    The color light gray. 
      magenta      The color magenta. 
      orange       The color orange. 
      pink         The color pink. 
      red          The color red. 
      white        The color white. 
      yellow       The color yellow.
        

Questions About Youguess2.java

  1. Shouldn't the function we use in Youguess2 need to return three things (for greater, equal or less?

    The way it is described in the assignment, the function should perform all the necessary inputs and outputs (i.e., it should prompt for the guess, read the guess, do an if/else to decide if it is too big or too small, or equal and print these messages, and return a true if the user guessed the number and false if she did not guess the number. In the main program, you will then call this function, see if it returned true, and go to the next choice only if it didn't.


Questions About Darts.java

  1. I print the points for the different parts of the board, but only one seems to show up. Why?

    Make sure you set the penColor to black before you draw the message. I have heard reports from another student of the same problem, and seems this may be another Cafe quirk hich I have not seen.

  2. How do I draw one ring of my dart board? Is there a Ring class?

    Sorry, but no, there is no Ring class. You need to draw three filled Circles. You just have to be careful to draw them in the right order. If you draw the bulls-eye first, then drawing the middle ring will "overwrite" the bulls-eye. So, do it in the opposite order!

  3. What is the return type of the drawDartBoard function?

    The header of this function looks like this:

    public void drawDartBoard(...)

    You need to replace the ... with the parameter declarations. The return type is void because nothing is being returned by the function.

    Do not use static in the header of any applet functions! (I should really cover the classes soon, otherwise more people would be confused by this.)

  4. May I add additional parameters to my function definitions, or do I have to stick with the exact interface specified on the lab assignment?

    You may enhance the functions to make them more flexible and more powerful. Just don't reduce any of their capabilities.

  5. I am trying to write my drawDartBoard function and the program fails when I attempt to execute. The error message says "Can't make static reference to method void setPenColor(java.awt.Color) in ccj.GraphicsApplet." Does this mean I cannot specify a pen color in my function?

    No, it means that you've got the static qualifier in your function header. See question 3 above.


Last modified: Tue Mar 9 15:17:05 EST 1999