2A

You are going to practice using some String methods. Complete the class called StringFun.

Do the following

You must use the String replace() method with strings of the replacemrnt character. No credit for simply printing the word with replacements or replacing the entire word.

For the draft, just print the length of the string multiplied by 2.


2A draft:
2A final:

2B

Finish LetterViewer class to print the letters "K", "O", and "K". Make the "O" red, but leave the "K's" black. After you create a project in Bluej, create a class called LetterViewer and copy in the code form Codecheck. Then you need to click Project tab again and click Import..., then navigate to where you downloaded the graphics package from Udacity and select it.You may get an warning. Just click "OK". If you have not downloaded the graphics classes from Udacity, do so now. The link is in the syllabus area.

First "K"

The "O"

Second "K"

You will need to find the coordinates of the other points. I recommend drawing a diagram.

For the draft, Draw the "O" in the correct position. Leave it black.

Here is an image of the final

screen shot of KOK

2B draft:
2B final:

2C

Finish the class FlowerViewer to draw a flower like the one below. You need to import the Udacity graphics package. You will not use all the classes but it is easier just to import all of them.

Use circles for the four petals and the center. The upper left-hand corner of the surrounding rectangle for the top petal of the flower is at (50, 10) . The radius of the circles for the petal is 15. The center is at (50, 40). Its radius is also15. You calculate the location of the other petals. Each petal and the center will touch at one point.

Make the center yellow using Color.YELLOW. Create a custom color for the petals with red = 200, green = 0, blue = 200. Be sure to use the fill() method

For the draft, draw the circle for the center of the petal. Make it yellow.

In the final, draw the center first and then the petals to get all the pixels in the right location for Codecheck.

Hint: You are given the radii of the circles but the Ellipse constructor requires width and height.

screen shot of flower output

2C draft:
2C final