2A
Complete the application RectangleObject
. A Rectangle
object has been created for you in the starter file.
Do the following:
Rectangle
class' methods getWidth
and getHeight
. Do not use the numbers directly. grow
method to decrease the width by 20 and to increase the height by 40. (Remember that the grow method adds the both sides and to top and bottom of the Rectangle.) Print the new area. Again, use the getWidth
and getHeight
methods. Rectangle
10 pixels to the the right and 30 pixels down. Get the left-most x value of the rectangle using getX
and print it.Hint: You can decrease the size of the Rectangle by using a negative number as a parameter in the grow method.
Note: Your code will be run twice - once with the values 50, 10 for width and height and once with two different values for width and height. You do not need to worry about that. It will happen automatically. If your code is correct, you will get the correct answers
For the draft, calculate and print the area of the original rectangle. Do not grow or translate
2B
In this problem you will use various String methods. Complete the class StringPlay
Remember that replace is an accessor method. It returns the changed version of the string. If you want to do something with the returned string - like use replace on it again - you need to save the return value in a variable.
You must use the String replace method on strings of one character. No credit for simply printing the word with the replacements or replacing the entire word.
Note: When you submit your code to Codecheck, it will first run with the given word, but then it will run again with a different word. You do not need to worry about that. It will happen automatically. If your code is correct,
For the draft, just print the length of the string mnus 1. Note: There is a String method length() which returns the length of the String
2C
Finish the application SnowmanDrawing to draw a snowman consisting of 3 circles centered on top of one another with a hat on top. The centers of the circles fall on a vertical line. The drawing will looks like this:
The dotted rectangle is the bounding rectangle of the middle circle. It is not part of your drawing.
Specifications:
For the draft, fill the hatbox and draw the brim.
Getting the Udacity graphics package
For this problem, you will use the Udacity graphics package. After you create your project, you will need to import the graphics package into it. Download the graphics package from Udacity and put it in a convenient location. Select the workbench for your project. Click Import... Navigate to the graphics package and select it. You may get a warning. Just click Continue