MirroredPictures - setSize(APPLET_WIDTH APPLET_HEIGHT Draws...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
//******************************************************************** // MirroredPictures.java Author: Lewis and Loftus // // Solution to Programming Project 11.5 // // Demonstrates the use of recursion. //******************************************************************** import java.applet.Applet; import java.awt.*; public class MirroredPictures extends Applet { private final int APPLET_WIDTH = 320; private final int APPLET_HEIGHT = 320; private final int MIN = 20; // smallest picture size private Image world, everest, goat; //----------------------------------------------------------------- // Loads the images. //----------------------------------------------------------------- public void init() { world = getImage (getDocumentBase(), "world.gif"); everest = getImage (getDocumentBase(), "everest.gif"); goat = getImage (getDocumentBase(), "goat.gif");
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: setSize (APPLET_WIDTH, APPLET_HEIGHT); } //-----------------------------------------------------------------// Draws the three images, then calls itself recursively. //-----------------------------------------------------------------public void drawPictures (int x, int y, int size, Graphics page) { page.drawImage (everest, x, y + size/2, size/2, size/2, this); page.drawImage (goat, x + size/2, y, size/2, size/2, this); page.drawImage (world, x, y, size/2, size/2, this); if (size > MIN) drawPictures (x + size/2, y + size/2, size/2, page); } //-----------------------------------------------------------------// Performs the initial call to the drawPictures method. //-----------------------------------------------------------------public void paint (Graphics page) { drawPictures (0, 0, APPLET_WIDTH, page); } }...
View Full Document

{[ snackBarMessage ]}

Ask a homework question - tutors are online