[Tutor] 15 puzzle (fwd)

Sheila King sheila@thinkspot.net
Sat, 28 Apr 2001 23:51:04 -0700


On Sat, 28 Apr 2001 23:32:44 -0700 (PDT), Daniel Yoo
<dyoo@hkn.eecs.berkeley.edu>  wrote about [Tutor] 15 puzzle (fwd):

Here are the  contents of the MS Word document:

/*
  The 15 Applet.
  You can do whatever you want with the code. You can use it, modify it,
  delete it. You can even print it out and burn it, or you can burn it
  without printing it out, but then please do be very carefull, for I 
  heard that monitors, hard drives and computers in general don't behave
  well under high temperatures. Just don't hold me responsible if it does
  anything, um, not so good to your computer.

  There is one thing I do ask:
  This is my first Java effort, so I don't know the language very well.
  I'm almost sure that some things here are quite incorrect, even though
  they do work. Never mind the algorithms themselves, but if you do find
  anything that needs to be changed, please send me a message at
  eugene@interlog.com Thank you.
*/
import java.applet.*;
import java.awt.*;
//--------------------------------------------------------------------------
public class fifteen extends Applet
{
   private SevenSegmentDigit[] display = new SevenSegmentDigit[3];
   private Button[] Buttons = new Button[16]; //This array is an actuall
playfield.
   private Button shuffleBtn = new Button ("&Shuffle");
   private int score=0;
   private int shuffling=0;						  
   private Font f;
/*---------------------------------------------------------------*/
	public String getAppletInfo() //Do I need this function?
	{
		return "Name: fifteen\r\n" +
		       "Author: Eugene\r\n" +
		       "Created with Microsoft Visual J++ Version 1.0";
	}

/*---------------------------------------------------------------*/
	public void init()
	{
		int i=0;
		String str=new String();

		resize(200, 300);
		setLayout(null); //Why do they bother so hard with layouts?
		setBackground(Color.black);

		for(i=0; i3)
					  moveBtn(empty-4);
				  return true;
		
		case Event.LEFT: if(empty % 4 !=3)
					  moveBtn(empty+1);
			      return true;

		case Event.RIGHT: if(empty % 4 != 0)
					  moveBtn(empty-1);
			      return true;

        case 's':
		case 'S': shuffle();
			      return true;
		}
	  return false;
	}
/*---------------------------------------------------------------*/
	public boolean action(Event evt, Object what)
	{
		int i=0;
	 
			for(i=0;i


--
Sheila King
http://www.thinkspot.net/sheila/
http://www.k12groups.org/