{"id":45271,"date":"2021-09-05T00:07:19","date_gmt":"2021-09-05T00:07:19","guid":{"rendered":"https:\/\/papersspot.com\/blog\/2021\/09\/05\/java-checking-for-winners-and-managing-the-game\/"},"modified":"2021-09-05T00:07:19","modified_gmt":"2021-09-05T00:07:19","slug":"java-checking-for-winners-and-managing-the-game","status":"publish","type":"post","link":"https:\/\/papersspot.com\/blog\/2021\/09\/05\/java-checking-for-winners-and-managing-the-game\/","title":{"rendered":"Java. Checking for Winners and Managing the Game"},"content":{"rendered":"<p>Basically, checking the board to see if anyone has won and if there are more spaces to be selected. <br \/>import javax.swing.*; <br \/>import java.awt.geom.*; <br \/>import java.awt.*; <br \/>import java.awt.event.*; <br \/>import java.awt.Color; <br \/>public class TicTacToe extends JPanel implements ActionListener <br \/>{ <br \/> JLabel greeting = new JLabel(&#8220;Tic Tac Toe&#8221;); <br \/> JLabel promptLabel = new JLabel(&#8220;Choose one button&#8221;); <br \/> JLabel result = new JLabel(); <br \/> Font headlineFont = new Font(&#8220;Helvetica&#8221;, Font.BOLD, <br \/> 20); <br \/> Font mediumFont = new Font(&#8220;Helvetica&#8221;, Font.BOLD, 14); <br \/> final int SIZE = 9; <br \/> final static int ROW_SIZE = 3; <br \/> final static int COL_SIZE = 3; <br \/> int x, y; <br \/> JButton[][] gameGrid = new JButton[ROW_SIZE][COL_SIZE]; <br \/> final static String BLANK = &#8221; &#8220;; <br \/> final static String XString = &#8220;X&#8221;; <br \/> final static String OString = &#8220;O&#8221;; <br \/> int row = 0, col = 0; <br \/> int num; <br \/> boolean spotFound; <br \/> boolean isDone = false; <br \/> boolean playersTurn = true; <br \/> boolean isWinPossible = false; <br \/> String msg = &#8220;&#8221;; <br \/> String gridString; <br \/> char winChar; <br \/> public static boolean checkForWinner(JButton [][] <br \/> gameGrid) <br \/> { <br \/> boolean isDone = false; <\/p>\n<p> \/\/ Your code goes here <br \/> \/\/ The code to check for winners needs to be implemented <br \/> \/\/ checkForWinner returns a boolean value representing a winner or not <\/p>\n<p> return isDone; <br \/> } <\/p>\n<p> public static boolean spacesRemain(JButton[][] grid) <br \/> { <\/p>\n<p> \/\/ Your code goes here <br \/> \/\/ spacesRemain returns a boolean value indicating that there are stillDigitsLeft <br \/> \/\/ spaces to be selected. <\/p>\n<p> return stillDigitsLeft; <br \/> } <br \/> public static void chooseSpot(JButton[][] gameGrid) <br \/> { <br \/> int x, y; <br \/> boolean placementMade = false; <br \/> for(x = 0; x &lt; ROW_SIZE<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Basically, checking the board to see if anyone has won and if there are more spaces to be selected. import javax.swing.*; import java.awt.geom.*; import java.awt.*; import java.awt.event.*; import java.awt.Color; public class TicTacToe extends JPanel implements ActionListener { JLabel greeting = new JLabel(&#8220;Tic Tac Toe&#8221;); JLabel promptLabel = new JLabel(&#8220;Choose one button&#8221;); JLabel result = new [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[28],"class_list":["post-45271","post","type-post","status-publish","format-standard","hentry","category-research-paper-writing","tag-computer-science"],"_links":{"self":[{"href":"https:\/\/papersspot.com\/blog\/wp-json\/wp\/v2\/posts\/45271","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/papersspot.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/papersspot.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/papersspot.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/papersspot.com\/blog\/wp-json\/wp\/v2\/comments?post=45271"}],"version-history":[{"count":0,"href":"https:\/\/papersspot.com\/blog\/wp-json\/wp\/v2\/posts\/45271\/revisions"}],"wp:attachment":[{"href":"https:\/\/papersspot.com\/blog\/wp-json\/wp\/v2\/media?parent=45271"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/papersspot.com\/blog\/wp-json\/wp\/v2\/categories?post=45271"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/papersspot.com\/blog\/wp-json\/wp\/v2\/tags?post=45271"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}