Sunday, April 27, 2014

Drawing a checkerboard
































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































Hey guys!































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































here is a program that is suppose to display a checkerboard on an applet as shown below but it is not.































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































I really do not know where I am wrong. I have spinned my brain to no avail.































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































kindly help me see where I am wrong.































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































kind regards
































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































/*































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































23.7 (Draw a Checkerboard Pattern) Write an applet that draws a checkerboard pattern as follows:
































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































* * * * * * * *































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































* * * * * * * *































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































* * * * * * * *































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































* * * * * * * *































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































* * * * * * * *































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































* * * * * * * *































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































* * * * * * * *































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































* * * * * * * *































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































*/































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































import java.awt.Graphics;































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































import javax.swing.JApplet;
































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































public class Exercise23_7 extends JApplet































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































{































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































// method paint to paint a checker board pattern































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































public void paint( Graphics g )































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































{
































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































// calling superclass version of method paint































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































super.paint( g );































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































// local variables































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































int location1 = 0;































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































//int location2 = 50;































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































int location3 = 50;































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































int location4 = 60;































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































// drawing a rectanglle where to display the results































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































g.drawRect( 10, 17, 400, 350 );
































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































// drawing the checker board pattern































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































for( int i = 1; i <= 4; i++ )































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































{































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































for( int location2 = 50; location2 <= 50; location2 +=10 )































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































{































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































location1 = 40;
































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































for( int j = 1; j <= 8; j++ )































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































{































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































location1 += 10 ;































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































g.drawString( "*", location1, location2 );































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































} // end for
































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































for( int j = 1; j <= 8; j++ )































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































{































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































location3 += 10;































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































g.drawString( "*", location3, location4 );































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































} // end for































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































} // end for































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































} // end outer for































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































} // end method paint































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































} // end class Exercise23_7































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































No comments:

Post a Comment