Quilt - pattern2 = new QuiltPattern (Color.cyan, Color.red,...

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

View Full Document Right Arrow Icon
//******************************************************************** // Quilt.java Author: Lewis and Loftus // // Solution to Programming Project 4.9 //******************************************************************** import javax.swing.JApplet; import java.awt.Color; import java.awt.Graphics; public class Quilt extends JApplet { private final int MAX_ROWS = 10, MAX_COLS = 10; private QuiltPattern pattern1, pattern2, currentPattern; //---------------------------------------------------------------- // Creates the pattern objects for the quilt. //---------------------------------------------------------------- public void init () { pattern1 = new QuiltPattern (Color.yellow, Color.blue, true);
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: pattern2 = new QuiltPattern (Color.cyan, Color.red, false); setSize (240, 240); setBackground (Color.black); } //----------------------------------------------------------------// Draws the quilt. //----------------------------------------------------------------public void paint (Graphics page) { for (int row=1; row <= MAX_ROWS; row++) { if (row % 2 != 0) currentPattern = pattern1; else currentPattern = pattern2; for (int col=1; col <= MAX_COLS; col++) { currentPattern.draw (page, row, col); if (currentPattern == pattern1) currentPattern = pattern2; else currentPattern = pattern1; } } } }...
View Full Document

This note was uploaded on 05/17/2011 for the course COP 3530 taught by Professor Davis during the Spring '08 term at University of Florida.

Ask a homework question - tutors are online