Complete the MadMax
program by filling in the max
method that returns the larger of its two parameters:
private int max(int i, int j)
The run method has already been written:
public void run() { println("The max of 4 and 5 is: " + max(4, 5)); println("The max of -4 and 4 is: " + max(-4, 4)); println("The max of 1 and 2 is: " + max(1, 2)); println("The max of 0 and 0 is: " + max(0, 0)); }
Your output should look like this:
Example:
Draw People,
Half Green
Day4: DrawTrees.java
Fill in the drawTree
method that draws a tree with the base of its trunk centered at the provided (x, y) position:
private void drawTree(int x, int y)
The run
method has already been written, which adds a dark-green background and draws some trees:
public void run() { setBackground(new Color(2, 110, 70)); drawTree(50, 150); drawTree(100, 300); drawTree(500, 200); drawTree(300, 250); drawTree(700, 310); }
Each tree should have a trunk with a width of 20 pixels and a height of 80 pixels. The leaves should have a radius of 30 pixels. The center of the leaves should be at the top center of the trunk. Your output should look like this:
If you finish early, see how beautiful a tree you can create. Email us a screenshot!