My Java Tortoise and Hare Applet will not run -


i trying create/simulate tortoise vs. hare race. random number generator used make competitors move....the possible moves being :a distance of 3 squares right, 1 square right, 6 squares left, 9 squares right, 1 square right, 12 squares left, 2 squares left, fall asleep. course plotted 50 squares of positions each player having own respective lanes , starting @ position 1. problems applet compiles, not run when try open html file in browser. on right track? how run....and when runs, properly?

import java.awt.*; import java.applet.*; public class project2 extends applet {      image tortoise, hare;     int tortx = 250, harex = 250;     final int torty = 100, harey = 300, width = 15, height = 50; int turn; string turnnum; int move; string tmove, hmove; public void init() {     tortoise = getimage( getdocumentbase(), "images/tortoise.gif" );     hare = getimage( getdocumentbase(), "images/hare.gif" );     move = 0; turn = 0; } public void control() {     while (( tortx < 985 ) || ( harex < 985 ))     {         move = (int)(10 * math.random());         switch (move)         {             case 1:             case 2:                 tortx += (3 * width);                 harex += (9 * width);                 tmove = "fast plod"; hmove = "big hop";                 break;             case 3:             case 4:             case 5:                 tortx += (3 * width);                 harex += width;                 tmove = "fast plod"; hmove = "small hop";                 break;             case 6:                 tortx += width;                 if (harex == 250) {} // agit nihil                  else if (harex <= (250 + (11 * width)))                     harex = 250;                 else                     harex -= (12 * width);                 tmove = "slow plod"; hmove = "big slip";                 break;             case 7:             case 8:                 tortx += (1 * width);                 if (harex == 250) {} // agit nihil                 else if (harex <= (250 + (width)))                     harex = 250;                 else                     harex -= (2 * width);                 tmove = "slow plod"; hmove = "small slip";                 break;             case 9:             case 10:                 if (tortx == 250) {} // agit nihil                 else if (tortx <= (250 + (5 * width)))                     tortx = 250;                 else                     tortx -= (6 * width);                 tmove = "slip"; hmove = "fall asleep.";                 break;                 // cuniculus dormit, agit nihil .         }         turn++; turnnum = (turn + "");         repaint();         (int = 1; <= 10; i++)         {             delay();         }     }     tortx = 985; harex = 985;     repaint(); } public void paint( graphics screen ) {     drawrace(screen);     if (tortx >= 985)     {         screen.setfont(new font("times new roman", font.italic, 48));         screen.drawstring("tortoise wins", 650, 240);         clearcurrent(screen);         fillnext(screen);     }     else if (harex >= 985)     {         screen.setfont(new font("times new roman", font.italic, 48));         screen.drawstring("tortoise wins", 650, 240);         clearcurrent(screen);         fillnext(screen);     }     else     {               screen.drawstring(("turn " + turnnum), 621, 55);         screen.setfont(new font("times new roman", font.italic, 12));         screen.drawstring(tmove, 59, 65); screen.drawstring(hmove, 66, 255);         clearcurrent(screen);         fillnext(screen);     }     stop(); } public void clearcurrent( graphics s ) {     s.clearrect(tortx+1, torty+1, width-1, height-1);     s.clearrect(harex+1, harey+1, width-1, height-1); } public void fillnext( graphics s ) {     s.fillrect(tortx+1, torty+1, width-1, height-1);     s.fillrect(harex+1, harey+1, width-1, height-1); } public void drawrace( graphics s ) {     // initium     s.drawrect(250, 100, 750, 50);     s.drawrect(250, 300, 750, 50);     int linex = 265, lineyi = 100, lineyf = 150;     (int = 1; <= 98; i++)     {         if (linex == 1000)         {             linex = 265; lineyi = 300; lineyf = 350;         }         s.drawline(linex, lineyi, linex, lineyf);         linex += 15;     }     s.fillrect(tortx+1, torty+1, width-1, height-1);     s.fillrect(harex+1, harey+1, width-1, height-1);     s.drawimage(tortoise, 59, 80, this);     s.drawimage(hare, 66, 271, this);     s.setfont(new font("times new roman", font.bold, 24));     s.drawstring("race", 250, 55); } public void delay() {     (int = 0; < 90000000; i++)     {     } } public void stop() { } 

}


Comments

Popular posts from this blog

Unable to remove the www from url on https using .htaccess -