Do not submit anything as part of today's lab!
draw method, and verify that it draws a colored face like the one below. Experiment with the setBlackAndWhite() and setColor() methods until you're sure you understand what they do to the picture.
draw method so that it uses this new color information when drawing the nose.
noseColor. Take a look at the color field in the Circle class if you need some help — our field declaration will look just the same, except for the field's name.
color of type String. You can look at the changeColor method in the Circle class for inspiration if you like — it's an example of a method that expects a color to be passed as an argument. (They call their parameter newColor, but we'll just call ours color.) Do not add a changeColor method to your Face class though. The goal here is to modify the constructor so that it takes an argument specifying the color of the nose.
draw method is invoked —
but draw can't see the constructor's parameter. (Parameters, like locally-declared variables are only visible within a particular method.) That is,
the user told the constructor what color they wanted the nose to
be, but we need to get that information to the other methods in the
class. We'll use an assignment statement to store the nose color
in a field, and access the field in draw when
restoring the nose's color. For now, just add this line to the
constructor:
noseColor = color;
This will take the parameter's value and store it in our noseColor field.
draw method that will change the nose's color to noseColor.
draw method that create the mouth and put it where it should be. (Don't worry about extending the setBlackAndWhite or setColor methods to deal with the mouth for now.) Make sure your mouth-drawing code works before going to the next step.
boolean that specifies whether we want the mouth to be created or not.
drawMouth to hold the new boolean value, and write an assignment statement in the constructor that stores the parameter's value into the field.
boolean named isMouth. When passing more than one parameter, the arguments must be separated by a comma. (See Triangle's changeSize method for an example of this.)
draw, write an if statement that encloses the mouth-drawing statements. The basic format is as follows:
if (drawMouth) {
// Statements that draw the mouth
}
makeVisible calls to the end of the draw method? To the beginning of the method?
setColor so that the nose comes out to be noseColor. (You can modify setBlackAndWhite to make a white nose while you're at it, too.)
setBlackAndWhite method so that it makes the mouth white. This is trickier than it sounds, since there isn't always a mouth!
You can use an if(mouth != null) statement inside the if(head != null) statement to control whether you try to set the mouth to white.
setColor method so that sets the mouth back to its original color, but only if the mouth is being displayed.