Question: why is my code not showing up the x ' s and o ' s in my display? here is my code. package games.boards; import
why is my code not showing up the xs and os in my display? here is my code.
package games.boards;
import java.awt.event.ActionEvent;
import javax.swing.;
import javax.swing.JFrame;
import javax.swing.SwingUtilities;
import games.utilities.FileManager;
import java.awt.event.ActionEvent;
@SuppressWarnings "serial", "unused"
public class BoardGameTester extends JFrame
private Board gb;
private int turn;
public static void mainString args
SwingUtilities.invokeLaternew Runnable
public void runnew BoardGameTester;
;
private void takeTurnCell c
Mark curMark turn
Mark.NOUGHT: Mark.CROSS;
gbsetCellcurMarkcgetRowcgetColumn;
private BoardGameTester
gb new Board new ActionListener
public void actionPerformedActionEvent ae
Cell c Cell aegetSource;
takeTurnc;
;
this.addgb;
this.setDefaultCloseOperationEXITONCLOSE;
this.setTitleTICTACTOE";
this.setSize;
this.setVisibletrue;
package games.boards;
import javax.swing.JButton;
import java.awt.Graphics;
import java.awt.GraphicsD;
import java.awt.BasicStroke;
import java.awt.Color;
import java.util.Scanner;
import java.awt.;
class Cell extends JButton
private Mark content;
private int row, column;
public Cellint row, int column
this.row row;
this.column column;
content Mark.EMPTY;
public Mark getContent
return content;
public void setContentMark content
this.content content;
public int getRow
return row;
public int getColumn
return column;
@Override
public void paintComponentGraphics g
super.paintComponentg;
int offset ;
GraphicsD gGraphicsD g;
gsetStrokenew BasicStroke;
switch content
case NOUGHT:
gsetColorColorRED;
gdrawOvaloffsetoffset,
this.getWidthoffset,
this.getHeightoffset;
break;
case CROSS:
gsetColorColorBLACK;
gdrawLine
offset, offset,
this.getWidth offset
this.getHeight offset ;
gdrawLine
this.getWidth offset,
offset, offset,
this.getHeight offset;
break;
public void addActionListenerActionListener ah
package games.boards;
import javax.swing.;
import java.awt.GridLayout;
@SuppressWarningsserial
public class Board extends JPanel
private Cell cells;
public Boardint rows, int columns, ActionListener ah
cells new Cellrowscolumns;
this.setLayoutnew GridLayout;
for int r ; r cells.length; r
for int c ; c cellsrlength; c
cellsrc new Cellrc;
this.addcellsrc;
cellsrcaddActionListenerah;
public void setCellMark mark, int row, int column throws IllegalArgumentException
try
if cellsrowcolumngetContent Mark.EMPTY
cellsrowcolumnsetContentmark;
else
throw new IllegalArgumentExceptionplay already occupied";
catch IllegalArgumentException e
System.out.printlninvalid cell selection";
@Override
public String toString
StringBuilder str new StringBuilder;
for int r ; r ; r
strappend;
for int c ; c ; c
switchcellsrcgetContent
case NOUGHT:
strappend;
break;
case CROSS:
strappendX;
break;
case YELLOW:
strappendY;
break;
case RED:
strappendR;
break;
case BLUE:
strappendB;
break;
case GREEN:
strappendG;
break;
case MAGENTA:
strappendM;
break;
case ORANGE:
strappendO;
break;
default: Empty
strappend ;
strappend;
strappend;
return strtoString;
package games.boards;
public class GridLayout
public GridLayout
TODO Autogenerated constructor stub
public static void mainString args
TODO Autogenerated method stub
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
