User Tools

Site Tools


checkerboard

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
checkerboard [2024/10/29 13:12] frchrischeckerboard [2024/10/29 13:15] (current) frchris
Line 2: Line 2:
  
 Make a checkerboard Make a checkerboard
 +
 +
 +Write a graphical application that displays a checkerboard with 64 squares, alternating white and black.
 +
 +Use nested loops.  Hint:  You can add the row and column, and if it is odd make it one color, and if it is even, you can made it the other color.
 +
  
 <code java CheckerBoard.java> <code java CheckerBoard.java>
Line 60: Line 66:
 </code> </code>
  
 +
 +<code java CheckerBoardViewer.java>
 +import javax.swing.JFrame;
 +
 +/**
 +   This program displays a checkerboard.
 +*/
 +public class CheckerBoardViewer
 +{
 +   public static void main(String[] args)
 +   {
 +      JFrame frame = new JFrame();
 +
 +      final int FRAME_WIDTH = 330;
 +      final int FRAME_HEIGHT = 360;
 +
 +      frame.setSize(FRAME_WIDTH, FRAME_HEIGHT);
 +      frame.setTitle("CheckerBoardViewer");
 +      frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
 +
 +      CheckerBoardComponent component = new CheckerBoardComponent();
 +      frame.add(component);
 +
 +      frame.setVisible(true);
 +   }
 +}
 +</code>
checkerboard.1730221940.txt.gz · Last modified: 2024/10/29 13:12 by frchris

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki