class19-Recursion.java

Getcolornew locationrow colgetred 0

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

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Of Hanoi"); g.setLineColor(new Color(128, 128, 128)); int row; for (row = 0; row < 7; row = row + 1) { int col; col = 0; for (col = 0; col <= row; col = col + 1) { g.setColor(new Location(row, col), new Color(255, 255, 255)); } } Recursion.waitForKeyPress(g); Recursion.move(g, 7, 0, 2, 1); } public static int burn(Grid g, Location loc) { if (!g.isValid(loc) || !g.getColor(loc).equals(new Color(0, 255, 0))) { return 0; } else { g.setColor(loc, new Color(255, 255, 0)); //yellow Recursion.waitForKeyPress(g); g.setColor(loc, new Color(255, 0, 0)); //red int row; int col; row = loc.getRow(); col = loc.getCol(); int burned; //USE RECURSIVE CALLS TO CALCULATE burned burned = 1 + Recursion.burn(g, new Location(row -...
View Full Document

This note was uploaded on 09/14/2010 for the course CS 15-100 taught by Professor Dave during the Spring '08 term at Carnegie Mellon.

Ask a homework question - tutors are online