\\JamesWilliams period 5 import java.awt.*; import java.awt.event.*; import java.applet.*; import java.util.Random; import javax.swing.*; public class JDub extends Applet { // These are all global / class variables. private int size; private String lastLetter; private int rows; private int cols; private int rowsXcols; private int moveCounter = 0; private int moveCounterUpdated = 0; private Graphics g; // rects is a matrix of rectangles. private Rectangle rects[][]; // scramble is declared as a static array of boolean values. private boolean scramble[]; // matrix is declared as a two dimentional static array of Strings. private String matrix[][]; // rnd is declared as an object of the Random class. private Random rnd; // blankR is declared as an integer variable to indicate a blank row number. private int blankR; // blankC is declared as an integer variable to indicate a column number. private int blankC; private String label = null; private int cellSize; private String player; private Button _myButton; int r1 = 0; int r2 = 255; int g1 = 0; int g2 = 255; int b1 = 0; int b2 = 255; color ThemeBC = new color(r1,g1,b1); color ThemeF = new color(r2,g2,b2); public static void main(String ad[]) { JFrame jwill = new JFrame(); JDub a=new JDub(); jwill.getContentPane().add(a, BorderLayout.CENTER); jwill.setSize(new Dimension(700,700)); jwill.setResizable(false); jwill.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); jwill.setVisible(true); // Create the menu bar JMenuBar menuBar = new JMenuBar(); // Create a menu JMenu menu = new JMenu("Theme"); menuBar.add(menu); // Create a menu item JMenuItem item = new JMenuItem("Xmas"); item.addActionListener(actionListener); menu.add(item); // Install the menu bar in the frame jwill.setJMenuBar(menuBar); } public void init() { _myButton = new Button (getParameter ( "label")); _myButton.addActionListener ( new AbstractAction () { public void actionPerformed ( ActionEvent event) { Frame f = new Frame("Frame"); f.pack(); f.show(); } } ); add (_myButton); } //////////////////////////////////////////////////////////////////////////////////////////////// /* The init method is a void method used to initialize the class variables. */ { player = ""; // This is a call to the enterSizeAndPlayersName method. enterSizeAndPlayersName(); /** size is a global variable returned by the above method. * size is the number of rows and columns for this puzzle. * 540 pixels is the size of the whole puzzle. Therefore the * cellSize of a 3 by 3 is 540/3 or 180 pixels.*/ if (size >= 2) cellSize = 400 / size; else cellSize = 540 / size; /** The size of the rects matrix, an object of the Rectangle * class, is determined by the values of row +1 & col +1. So * a 3 X 3 will have 4 rows and 4 columns.**/ rects = new Rectangle[rows + 1][cols +1]; for(int row = 1; row <= rows; row++) { for(int col = 1; col <= cols; col++) { int x = (col - 1) * cellSize + cellSize; int y = (row - 1) * cellSize + cellSize; rects[row][col] = new Rectangle(x,y,cellSize,cellSize); } } // matrix is defined here as a rows + 2 by cols + 2 matrix of Strings. matrix = new String[rows+2][cols+2]; // scramble is defined here as a rows by cols + 1 elements of booleans. scramble = new boolean[rowsXcols + 1]; // This for loop will fill the scramble array with 16 values of false. for (int k = 1; k <=rowsXcols; k++) scramble[k] = false; // rnd is defined as a Random object without a seed value. rnd = new Random(); // A 6 by 6 matrix is filled with the "#" pound sign as a String. for (int r = 0; r <= rows + 1; r++) for (int c = 0; c <= cols + 1; c++) matrix[r][c] = "#"; /* Then a 4 by 4 matrix is defined inside the 6 by 6 matrix but * starting at 1,1 instead of 0,0. This matrix will be filled * with letters supplied by the getLetter method with the last of the * sixteen letters (P) being blanked out by the if statement * if(matrix[r][c].equals("L")) */ for (int r = 1; r <= rows; r++) for (int c = 1; c <= cols; c++) { matrix[r][c] = getLetter(); if (matrix[r][c].equals(lastLetter)) { // Here the blankR varaible is defined as the r number that would // normally hold the letter lastLetter. blankR = r; // Here the blankC varaible is defined as the c number that would // normally hold the letter lastLetter. blankC = c; } } } // End of the init method //////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////// /** The enterSize method is a void method that will prompt the user for a 3 for a 3 X 3 grid, a * 4 for a 4 X 4 grid and a 5 for a 5 X 5 grid for the Letter Puzzle. **/ public void enterSizeAndPlayersName() { // Prompt the user for a grid size. String prompt = "Enter Play Level\n 3 - 3 X 3 Grid\n 4 - 4 X 4 Grid\n 5 - 5 X 5 Grid\n 6 - 6 X 6 Grid\n 7 - 7 X 7 Grid\n 8 - 8 X 8 Grid\n 9 - 9 X 9 Grid\n 10 - 10 X 10 Grid\n"; // Assign the number entered to a string variable named sizeString. String sizeString = JOptionPane.showInputDialog(prompt); String IdiotMax = "The max is 10 X 10 moron"; String IdiotMin = "The min is 2 X 2 idiot"; String tryagain = ""; // Convert sizeString into integer variable size using the parseInt method of Integer class. size = Integer.parseInt(sizeString); if (size > 10) { tryagain = IdiotMax + "! Would you like to try again?"; int retry = JOptionPane.showConfirmDialog(null, tryagain, "Click Yes or No:", JOptionPane.YES_NO_OPTION); if (retry == JOptionPane.YES_OPTION) {enterSizeAndPlayersName(); } else if (retry == JOptionPane.NO_OPTION) {System.exit(0);} } if (size < 2) { tryagain = IdiotMin + "! Would you like to try again?"; int retry = JOptionPane.showConfirmDialog(null, tryagain, "Click Yes or No:", JOptionPane.YES_NO_OPTION); if (retry == JOptionPane.YES_OPTION) {enterSizeAndPlayersName(); } else if (retry == JOptionPane.NO_OPTION) {System.exit(0);} } String playerNamePrompt = "Enter Your Full Name as the player. \n"; player = JOptionPane.showInputDialog(playerNamePrompt); // Size is the number of rows and columns in the grid. rows = size; cols = size; // A 3 by 3 grid will have 9 (3 * 3) cells. rowsXcols = rows * cols; // The size will determine the value of lastLetter variable. switch (size) { case 2: lastLetter = "4"; break; case 3: lastLetter = "9"; break; case 4: lastLetter = "16"; break; case 5: lastLetter = "25"; break; case 6: lastLetter = "36"; break; case 7: lastLetter = "49"; break; case 8: lastLetter = "64"; break; case 9: lastLetter = "81"; break; case 10: lastLetter = "100"; break; } } // End of the enterSize method /////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////// /* This is the getLetter method and it is called by the init method to get a letter * to draw in the 4 by 4 matrix inside the 6 by 6 matrix of #'s. */ public String getLetter() { // The String letter is initalized to an empty string. String letter = ""; // The boolean varaible Done is declared and defined as "false". boolean Done = false; // While Done is not true (false) this loop will continue. while(!Done) { // A new integer variable rndNum is declared and defined as a random // integer between 1 and 16. int rndNum = rnd.nextInt(rowsXcols) + 1; // If the scramble array at element rndNum is false (each element is the // array is defined as false), then the if statement is executed. if (scramble[rndNum] == false) { // Capital letter A is 65 in Unicode and ASCII codes. Therefore, the // rndNum + 64 will range between A and P. Here the String letter is // defined as the character of the value at rndNum + 64. letter = String.valueOf(rndNum); // The element at rndNum in the scramble array is declared to be true // so that the letters are only assigned once. Each time a letter is // assigned that recatangle's scramble value is turned to true. scramble[rndNum] = true; // The while loop will execute once and only once each time Done = true; } } return letter; } // End of the getLetter method /////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////// /* The paint method will draw the grid lines and each capital letter assigned to * each matrix point. */ public void paint(Graphics out) { // g is the global object of the Graphics class while output is the local variable. g=out; g.setColor(new Color(0,100,0)); g.fillRect(0,0,800,800); g.setColor(Color.BLUE); // This is a call to the drawGrid method and we are passing it the global variable g. drawGrid(g); // Font attributes are set here. g.setFont(new Font("Arial",Font.BOLD,20)); // Author's name is displayed. g.drawString("J-Will's Number Puzzle",20,40); // Moves Taken string is displayed at 390 x and 40 y. g.drawString("Moves Taken ",390,40); // The current player from the JOption pane input window is displayed at (20, 60). g.drawString("Current Player: " + player,40,60); // This is where the moveCounter will be displayed. g.drawRect(530, 15, 150, 50); // The moverCounter is shown as an empty string plus the number. String counter = "" + moveCounter; /** If the moverCounter is less than the moveCounterUpdated variable, then the * swap method has been called and the moveCounterUpdated++; statement has * added one to the moveCounterUpdated variable. That will cause the * moveCounter to be one less than the moveCounterUpdated. That is when the * old number needs to be blanked out with a white rectangle. **/ if(moveCounter < moveCounterUpdated) { // The color white is set. g.setColor(new Color(0,100,0)); // The display area for the moveCounter is painted white = blanked. g.fillRect(531,16,148,48); // After the area is blanked moveCounter is assigned moveCounterUpdated. moveCounter = moveCounterUpdated; } /** After moveCounter is updated a new number of moves needs to be displayed. **/ if(moveCounter == moveCounterUpdated) { // Change the color to burnt orange of UT is 204,85,0 or HTML CC5500. g.setColor(Color.RED); // Change the Font and Font size. g.setFont(new Font("Arial",Font.BOLD,49)); // Draw the number in the rectangle. g.drawString(counter,535,58); } for (int r = 1; r <= rows; r++) { for (int c = 1; c <= cols; c++) { int y = (r - 1) * cellSize + cellSize; int x = (c - 1) * cellSize + cellSize; drawLetter(g,matrix[r][c],x,y); } } } // End of the paint method ////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////// /* The drawGrid method will draw the outline and lines for the three by three grid. */ public void drawGrid(Graphics g) { for(int r = 1; r <= rows; r++) { for(int c = 1; c <= cols; c++) { int y = 20 + (r - 1) * cellSize + cellSize; int x = 10 + (c - 1) * cellSize + cellSize; g.drawRect(x,y,cellSize,cellSize); } } } // End of drawGrid method /////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////// /* The drawLetter will draw the appropiate letter in the appropiate matrix location * and it will be an Arial font that is bold and size 200. The offset will center * the letter inside the 200 by 200 square. unless the letter is an lastLetter, in which * case a blank is draw at that locaton. */ public void drawLetter(Graphics g, String letter, int x, int y) { g.setFont(new Font("Arial",Font.BOLD,cellSize - 10)); int offSetX = x + 12; int offSetY = y + 20 + (cellSize * 4 / 5 ); int offSetX2 = offSetX + 10; int offSetY2 = offSetY; int num = Integer.parseInt(letter); if (letter.equals(lastLetter)) { g.setColor(new Color(0,100,0)); g.fillRect(x+11,y+21,cellSize - 2,cellSize - 2); } else { if (num < 10) { g.setColor(Color.RED); g.drawString(letter,offSetX2, offSetY2); } else { g.setColor(Color.RED); g.drawString(letter,offSetX,offSetY); } } } // End of drawLetter method //////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////// /* * The mouseDown method will detect if the mouse is depressed inside one of the * 9 recatangles. It will also check to see if any of the 8 rectangles around * the current rectangle is empty(the one with the letter "I"), using the * okSquare() method. If both of those conditions are true then the letter * is swapped places with the letter "I". **/ public boolean mouseDown(Event e, int x, int y) { /* If you click in the rectangle and that rectangle has the letter I * in one of the four adjoining squares, then that letter is swapped with * the letter "I" which is the empty square because the last letter is the * series is made to be blank so that one square is always empty. */ for (int r = 1; r <= rows; r++) { for (int c = 1; c <= cols; c++) { if(rects[r][c].inside(x,y) && okSquare(r,c)) swap(r,c); } } return true; } //End of mouseDown method //////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////// /* The okSquare method is sent the row and column numbers * of the a 3 by 3 matrix location as defined by the r and * the c values. The square is OK if the square above [r-1], or * the square below [r+1], or the square to the left [c-1], or * the square to right [c+1] contains the letter "I" and is * therefore blank or empty. If any of those four conditions * are true then the value of true is returned and okSquare * condition is true. */ public boolean okSquare(int r, int c) { boolean temp = false; if (matrix[r-1][c].equals(lastLetter)) temp = true; else if (matrix[r+1][c].equals(lastLetter)) temp = true; else if (matrix[r][c-1].equals(lastLetter)) temp = true; else if (matrix[r][c+1].equals(lastLetter)) temp = true; return temp; } // End of okSquare method /////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////// /* The row and column number of the blank square is swapped with * the row and column number passed to this method and then the * entire applet is redrawn with repaint() method. */ public void swap(int r, int c) { moveCounterUpdated ++; matrix[blankR][blankC] = matrix[r][c]; matrix[r][c] = lastLetter; blankR = r; blankC = c; repaint(); youwin(g); } // End of swap method /////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////// public void youwin(Graphics g) { String mn = ""; if (moveCounterUpdated <= 1) { moveCounterUpdated = 1; mn = " move!!!";} else { mn = " moves!";} String Winner = "Congrats " + player + " on solving the " + size + " by " + size + " puzzle in " + moveCounterUpdated + mn; String Loss = "TROLOLOLOLO, You can not win them all!!!!!!!!!!!!"; if (size >= 6) {Winner = Winner + "\n What? Would you like a cookie???";} boolean Win = false; boolean lose = false; switch (size) { case 2: Win = win2x2(); lose = lose2x2();break; case 3: Win = win3x3();break; case 4: Win = win4x4();break; case 5: Win = win5x5();break; case 6: Win = win6x6();break; case 7: Win = win7x7();break; case 8: Win = win8x8();break; case 9: Win = win9x9();break; case 10: Win = win10x10(); } if(Win) { JOptionPane.showMessageDialog(this, Winner); System.exit(0); } if(lose) { JOptionPane.showMessageDialog(this, Loss); System.exit(0); } } public boolean lose2x2() { boolean lose = false; if(matrix[1][1].equals("2") && matrix[1][2].equals("1")) { lose = true; } return lose; } public boolean win2x2() { boolean win = false; if(matrix[1][1].equals("1") && matrix[1][2].equals("2") && matrix[2][1].equals("3")) { win = true; } return win; } public boolean win3x3() { boolean win = false; if(matrix[1][1].equals("1") && matrix[1][2].equals("2") && matrix[1][3].equals("3") && matrix[2][1].equals("4") && matrix[2][2].equals("5") && matrix[2][3].equals("6") && matrix[3][1].equals("7") && matrix[3][2].equals("8")) {win = true; } return win; } public boolean win4x4() { boolean win = false; if(matrix[1][1].equals("1") && matrix[1][2].equals("2") && matrix[1][3].equals("3") && matrix[1][4].equals("4") && matrix[2][1].equals("5") && matrix[2][2].equals("6") && matrix[2][3].equals("7") && matrix[2][4].equals("8") && matrix[3][1].equals("9") && matrix[3][2].equals("10") && matrix[3][3].equals("11") && matrix[3][4].equals("12") && matrix[4][1].equals("13") && matrix[4][2].equals("14") && matrix[4][3].equals("15") ) {win = true; } return win; } public boolean win5x5() { boolean win = false; if (matrix[1][1].equals("1") && matrix[1][2].equals("2") && matrix[1][3].equals("3") && matrix[1][4].equals("4") && matrix[1][5].equals("5") && matrix[2][1].equals("6") && matrix[2][2].equals("7") && matrix[2][3].equals("8") && matrix[2][4].equals("9") && matrix[2][5].equals("10") && matrix[3][1].equals("11") && matrix[3][2].equals("12") && matrix[3][3].equals("13") && matrix[3][4].equals("14") && matrix[3][5].equals("15") && matrix[4][1].equals("16") && matrix[4][2].equals("17") && matrix[4][3].equals("18") && matrix[4][4].equals("19") && matrix[4][5].equals("20") && matrix[5][1].equals("21") && matrix[5][2].equals("22") && matrix[5][3].equals("23") && matrix[5][4].equals("24")) { win = true; } return win; } public boolean win6x6() { boolean win = false; if (matrix[1][1].equals("1") && matrix[1][2].equals("2") && matrix[1][3].equals("3") && matrix[1][4].equals("4") && matrix[1][5].equals("5") && matrix[1][6].equals("6") && matrix[2][1].equals("7") && matrix[2][2].equals("8") && matrix[2][3].equals("9") && matrix[2][4].equals("10") && matrix[2][5].equals("11") && matrix[2][6].equals("12") && matrix[3][1].equals("13") && matrix[3][2].equals("14") && matrix[3][3].equals("15") && matrix[3][4].equals("16") && matrix[3][5].equals("17") && matrix[3][6].equals("18") && matrix[4][1].equals("19") && matrix[4][2].equals("20") && matrix[4][3].equals("21") && matrix[4][4].equals("22") && matrix[4][5].equals("23") && matrix[4][6].equals("24") && matrix[5][1].equals("25") && matrix[5][2].equals("26") && matrix[5][3].equals("27") && matrix[5][4].equals("28") && matrix[5][5].equals("29") && matrix[5][6].equals("30") && matrix[6][1].equals("31") && matrix[6][2].equals("32") && matrix[6][3].equals("33") && matrix[6][4].equals("34") && matrix[6][5].equals("35")) { win = true; } return win; } public boolean win7x7() { boolean win = false; if (matrix[1][1].equals("1") && matrix[1][2].equals("2") && matrix[1][3].equals("3") && matrix[1][4].equals("4") && matrix[1][5].equals("5") && matrix[1][6].equals("6") && matrix[1][7].equals("7") && matrix[2][1].equals("8") && matrix[2][2].equals("9") && matrix[2][3].equals("10") && matrix[2][4].equals("11") && matrix[2][5].equals("12") && matrix[2][6].equals("13") && matrix[2][7].equals("14") && matrix[3][1].equals("15") && matrix[3][2].equals("16") && matrix[3][3].equals("17") && matrix[3][4].equals("18") && matrix[3][5].equals("19") && matrix[3][6].equals("20") && matrix[3][7].equals("21") && matrix[4][1].equals("22") && matrix[4][2].equals("23") && matrix[4][3].equals("24") && matrix[4][4].equals("25") && matrix[4][5].equals("26") && matrix[4][6].equals("27") && matrix[4][7].equals("28") && matrix[5][1].equals("29") && matrix[5][2].equals("30") && matrix[5][3].equals("31") && matrix[5][4].equals("32") && matrix[5][5].equals("33") && matrix[5][6].equals("34") && matrix[5][7].equals("35") && matrix[6][1].equals("36") && matrix[6][2].equals("37") && matrix[6][3].equals("38") && matrix[6][4].equals("39") && matrix[6][5].equals("40") && matrix[6][6].equals("41") && matrix[6][7].equals("42") && matrix[7][1].equals("43") && matrix[7][2].equals("44") && matrix[7][3].equals("45") && matrix[7][4].equals("46") && matrix[7][5].equals("47") && matrix[7][6].equals("48")) { win = true; } return win; } public boolean win8x8() { boolean win = false; if (matrix[1][1].equals("1") && matrix[1][2].equals("2") && matrix[1][3].equals("3") && matrix[1][4].equals("4") && matrix[1][5].equals("5") && matrix[1][6].equals("6") && matrix[1][7].equals("7") && matrix[1][8].equals("8") && matrix[2][1].equals("9") && matrix[2][2].equals("10") && matrix[2][3].equals("11") && matrix[2][4].equals("12") && matrix[2][5].equals("13") && matrix[2][6].equals("14") && matrix[2][7].equals("15") && matrix[2][8].equals("16") && matrix[3][1].equals("17") && matrix[3][2].equals("18") && matrix[3][3].equals("19") && matrix[3][4].equals("20") && matrix[3][5].equals("21") && matrix[3][6].equals("22") && matrix[3][7].equals("23") && matrix[3][8].equals("24") && matrix[4][1].equals("25") && matrix[4][2].equals("26") && matrix[4][3].equals("27") && matrix[4][4].equals("28") && matrix[4][5].equals("29") && matrix[4][6].equals("30") && matrix[4][7].equals("31") && matrix[4][8].equals("32") && matrix[5][1].equals("33") && matrix[5][2].equals("34") && matrix[5][3].equals("35") && matrix[5][4].equals("36") && matrix[5][5].equals("37") && matrix[5][6].equals("38") && matrix[5][7].equals("39") && matrix[5][8].equals("40") && matrix[6][1].equals("41") && matrix[6][2].equals("42") && matrix[6][3].equals("43") && matrix[6][4].equals("44") && matrix[6][5].equals("45") && matrix[6][6].equals("46") && matrix[6][7].equals("47") && matrix[6][8].equals("48") && matrix[7][1].equals("49") && matrix[7][2].equals("50") && matrix[7][3].equals("51") && matrix[7][4].equals("52") && matrix[7][5].equals("53") && matrix[7][6].equals("54") && matrix[7][7].equals("55") && matrix[7][8].equals("56") && matrix[8][1].equals("57") && matrix[8][2].equals("58") && matrix[8][3].equals("59") && matrix[8][4].equals("60") && matrix[8][5].equals("61") && matrix[8][6].equals("62") && matrix[8][7].equals("63")) {win = true;} return win; } public boolean win9x9() { boolean win = false; if ( matrix[1][1].equals("1") && matrix[1][2].equals("2") && matrix[1][3].equals("3") && matrix[1][4].equals("4") && matrix[1][5].equals("5") && matrix[1][6].equals("6") && matrix[1][7].equals("7") && matrix[1][8].equals("8") && matrix[1][9].equals("9") && matrix[2][1].equals("10") && matrix[2][2].equals("11") && matrix[2][3].equals("12") && matrix[2][4].equals("13") && matrix[2][5].equals("14") && matrix[2][6].equals("15") && matrix[2][7].equals("16") && matrix[2][8].equals("17") && matrix[2][9].equals("18") && matrix[3][1].equals("19") && matrix[3][2].equals("20") && matrix[3][3].equals("21") && matrix[3][4].equals("22") && matrix[3][5].equals("23") && matrix[3][6].equals("24") && matrix[3][7].equals("25") && matrix[3][8].equals("26") && matrix[3][9].equals("27") && matrix[4][1].equals("28") && matrix[4][2].equals("29") && matrix[4][3].equals("30") && matrix[4][4].equals("31") && matrix[4][5].equals("32") && matrix[4][6].equals("33") && matrix[4][7].equals("34") && matrix[4][8].equals("35") && matrix[4][9].equals("36") && matrix[5][1].equals("37") && matrix[5][2].equals("38") && matrix[5][3].equals("39") && matrix[5][4].equals("40") && matrix[5][5].equals("41") && matrix[5][6].equals("42") && matrix[5][7].equals("43") && matrix[5][8].equals("44") && matrix[5][9].equals("45") && matrix[6][1].equals("46") && matrix[6][2].equals("47") && matrix[6][3].equals("48") && matrix[6][4].equals("49") && matrix[6][5].equals("50") && matrix[6][6].equals("51") && matrix[6][7].equals("52") && matrix[6][8].equals("53") && matrix[6][9].equals("54") && matrix[7][1].equals("55") && matrix[7][2].equals("56") && matrix[7][3].equals("57") && matrix[7][4].equals("58") && matrix[7][5].equals("59") && matrix[7][6].equals("60") && matrix[7][7].equals("61") && matrix[7][8].equals("62") && matrix[7][9].equals("63") && matrix[8][1].equals("64") && matrix[8][2].equals("65") && matrix[8][3].equals("66") && matrix[8][4].equals("67") && matrix[8][5].equals("68") && matrix[8][6].equals("69") && matrix[8][7].equals("70") && matrix[8][8].equals("71") && matrix[8][9].equals("72") && matrix[9][1].equals("73") && matrix[9][2].equals("74") && matrix[9][3].equals("75") && matrix[9][4].equals("76") && matrix[9][5].equals("77") && matrix[9][6].equals("78") && matrix[9][7].equals("79") && matrix[9][8].equals("80")) { win = true; } return win; } public boolean win10x10() { boolean win = false; if ( matrix[1][1].equals("1") && matrix[1][2].equals("2") && matrix[1][3].equals("3") && matrix[1][4].equals("4") && matrix[1][5].equals("5") && matrix[1][6].equals("6") && matrix[1][7].equals("7") && matrix[1][8].equals("8") && matrix[1][9].equals("9") && matrix[1][10].equals("10") && matrix[2][1].equals("11") && matrix[2][2].equals("12") && matrix[2][3].equals("13") && matrix[2][4].equals("14") && matrix[2][5].equals("15") && matrix[2][6].equals("16") && matrix[2][7].equals("17") && matrix[2][8].equals("18") && matrix[2][9].equals("19") && matrix[2][10].equals("20") && matrix[3][1].equals("21") && matrix[3][2].equals("22") && matrix[3][3].equals("23") && matrix[3][4].equals("24") && matrix[3][5].equals("25") && matrix[3][6].equals("26") && matrix[3][7].equals("27") && matrix[3][8].equals("28") && matrix[2][9].equals("29") && matrix[3][10].equals("30") && matrix[4][1].equals("31") && matrix[4][2].equals("32") && matrix[4][3].equals("33") && matrix[4][4].equals("34") && matrix[4][5].equals("35") && matrix[4][6].equals("36") && matrix[4][7].equals("37") && matrix[4][8].equals("38") && matrix[4][9].equals("39") && matrix[4][10].equals("40") && matrix[5][1].equals("41") && matrix[5][2].equals("42") && matrix[5][3].equals("43") && matrix[5][4].equals("44") && matrix[5][5].equals("45") && matrix[5][6].equals("46") && matrix[5][7].equals("47") && matrix[5][8].equals("48") && matrix[5][9].equals("49") && matrix[5][10].equals("50") && matrix[6][1].equals("51") && matrix[6][2].equals("52") && matrix[6][3].equals("53") && matrix[6][4].equals("54") && matrix[6][5].equals("55") && matrix[6][6].equals("56") && matrix[6][7].equals("57") && matrix[6][8].equals("58") && matrix[6][9].equals("59") && matrix[6][10].equals("60") && matrix[7][1].equals("61") && matrix[7][2].equals("62") && matrix[7][3].equals("63") && matrix[7][4].equals("64") && matrix[7][5].equals("65") && matrix[7][6].equals("66") && matrix[7][7].equals("67") && matrix[7][8].equals("68") && matrix[7][9].equals("69") && matrix[7][10].equals("70") && matrix[8][1].equals("71") && matrix[8][2].equals("72") && matrix[8][3].equals("73") && matrix[7][4].equals("74") && matrix[7][5].equals("75") && matrix[8][6].equals("76") && matrix[8][7].equals("77") && matrix[8][8].equals("78") && matrix[8][9].equals("79") && matrix[8][10].equals("80") && matrix[9][1].equals("81") && matrix[9][2].equals("82") && matrix[9][3].equals("83") && matrix[8][4].equals("84") && matrix[8][5].equals("85") && matrix[9][6].equals("86") && matrix[9][7].equals("87") && matrix[9][8].equals("88") && matrix[9][9].equals("89") && matrix[9][10].equals("90") && matrix[10][1].equals("91") && matrix[10][2].equals("92") && matrix[10][3].equals("93") && matrix[10][4].equals("94") && matrix[10][5].equals("95") && matrix[10][6].equals("96") && matrix[10][7].equals("97") && matrix[10][8].equals("98") && matrix[10][9].equals("99")) { win = true; } return win; } //////////////////////////////////////////////////////////////////////////////////////////////// /* The update method stops the screen flicker and has the same effect * as double buffering. */ public void update(Graphics g) { paint(g); } // End of update method ////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////// } // End of JDub class