Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This code was provided. Just need to complete the code. package edu.cuny.qc; import java.awt.*;import java.awt.event.*;import java.io.IOException; import java.net.MalformedURLException;import java.net.URL;import java.util.Scanner;import javax.swing.*; public class Sudoku extends

image text in transcribed

This code was provided. Just need to complete the code.

package edu.cuny.qc; import java.awt.*;import java.awt.event.*;import java.io.IOException; import java.net.MalformedURLException;import java.net.URL;import java.util.Scanner;import javax.swing.*; public class Sudoku extends JFrame implements ActionListener { private JButton[][] gridButton = new JButton[9][9]; // buttons that make up the Sudoku grid private JButton[] numberButton = new JButton[11]; // numbers and other command buttons int number = 1; // background colors of the grid public static final Color BEIGE = new Color(0xF5F5DC); public static final Color GAINSBORO = new Color(0xDCDCDC); // menu bar and menu options private MenuBar menuBar = new MenuBar(); private Menu menuFile = new Menu("File"); private Menu menuHelp = new Menu("Help"); private MenuItem menuNew = new MenuItem("New Puzzle"); private MenuItem menuFill = new MenuItem("Fill Grid"); private MenuItem menuFileExit = new MenuItem("Exit"); private MenuItem menuAbout = new MenuItem("About"); private MenuItem menuSudokuHelp = new MenuItem("Sudoku Help") public Sudoku() {// Add action listener for the new menu option menuNew.addActionListener (new ActionListener() {public void actionPerformed(ActionEvent e) { resetGrid(); } } );// Add action listener for the fill grid option menuFill.addActionListener (new ActionListener() { public void actionPerformed(ActionEvent e) { fillGrid(); } } ); // Add action listener for the about menu option menuAbout.addActionListener (new ActionListener() {public void actionPerformed(ActionEvent e) { ImageIcon icon = new ImageIcon("images/logo.jpg"); String message = "Sudoku version 0.99 Copyright \u00A9 2018 Andy Abreu"; JOptionPane.showMessageDialog(null,message,"Sudoku",JOptionPane.INFORMATION_MESSAGE,icon); } } ); // Add action listener for the help menu option menuSudokuHelp.addActionListener {new ActionListener() { public void actionPerformed(ActionEvent e) { ImageIcon icon = new ImageIcon("images/sudoku.jpg"); String message = "Complete the grid so that every row, column" + " and 3x3 box contains every digit from 1 to 9 inclusive." + " Click the button, at the bottom of the window, with the"+ " number you wish to enter, then click the button in the grid."+ " Click the pen to evaluate, and the pencil does nothing."; JOptionPane.showMessageDialog(null,message,"Sudoku Help",JOptionPane.INFORMATION_MESSAGE,icon); } } ); // Add action listener for the exit menu option menuFileExit.addActionListener ( new ActionListener() { public void actionPerformed(ActionEvent e) { Sudoku.this.windowClosed(); } } ); // add new, fill, and exit to the file menu menuFile.add(menuNew); menuFile.add(menuFill); menuFile.addSeparator(); menuFile.add(menuFileExit); // add about and help to the help menu menuHelp.add(menuAbout); menuHelp.add(menuSudokuHelp) // add menu options to menu bar menuBar.add(menuFile) menuBar.add(menuHelp) // add the menubar to the frame setMenuBar(menuBar) // create a panel with a grid layout for the grid JPanel panel1 = new JPanel(); panel1.setLayout(new GridLayout(9,9)); for(int i=0;i5) gridButton[i][j].setBackground(BEIGE); break; case 3: case 4: case 5:if(j>2 && j Sudoku is a logic game played on a 9x9 grid using the digits 1 through 9. The grid is further subdivided into nine 3x3 boxes. The goal is to fill in the grid with digits such that one and only one of each digit 1 through 9 appear in every row, column, and box. Create a program that determines whether or not a Sudoku grid filled with numbers is a Sudoku. Import program1.zip (distributed in class) into Eclipse. As discussed in class, make sure that the program is well documented and submitted on time. The code is incomplete, you will have to write the fillGrid and evaluate methods where indicated by the statement: JOptionPane.showMessageDialog(this, "Write the necessary code to ..."); The program starts with an empty grid (See Figure 1). Enter numbers into the grid so that every row, column and 3x3 box contains every digit from 1 to 9 inclusive (see Figure 2) To enter the numbers, click the button, at the bottom of the window, with the number you wish to enter, and then click the button in the grid into which the number should be placed Instead of entering the numbers, there is also an option in the File menu (Fill Grid) that can fill in the numbers read from a file. You will have to complete this code Sudoku1.txt, Sudoku2.txt, and Sudoku3.txt contain data that can be used to test your program The files are located in http://venus.cs.gc.cuny.edu/aabreu/cs212/project1/ After entering the numbers, click the pen (icon next to the 9) to evaluate the grid. You will also have to write the code for the evaluate method and display a message indicating whether or not the grid represents a Sudoku Sudoku v0.99 Sudoku va.99 File Help File Help 6 3 5 289 7 1 7 8 9 61 Figure 1 Figure 2 Sudoku is a logic game played on a 9x9 grid using the digits 1 through 9. The grid is further subdivided into nine 3x3 boxes. The goal is to fill in the grid with digits such that one and only one of each digit 1 through 9 appear in every row, column, and box. Create a program that determines whether or not a Sudoku grid filled with numbers is a Sudoku. Import program1.zip (distributed in class) into Eclipse. As discussed in class, make sure that the program is well documented and submitted on time. The code is incomplete, you will have to write the fillGrid and evaluate methods where indicated by the statement: JOptionPane.showMessageDialog(this, "Write the necessary code to ..."); The program starts with an empty grid (See Figure 1). Enter numbers into the grid so that every row, column and 3x3 box contains every digit from 1 to 9 inclusive (see Figure 2) To enter the numbers, click the button, at the bottom of the window, with the number you wish to enter, and then click the button in the grid into which the number should be placed Instead of entering the numbers, there is also an option in the File menu (Fill Grid) that can fill in the numbers read from a file. You will have to complete this code Sudoku1.txt, Sudoku2.txt, and Sudoku3.txt contain data that can be used to test your program The files are located in http://venus.cs.gc.cuny.edu/aabreu/cs212/project1/ After entering the numbers, click the pen (icon next to the 9) to evaluate the grid. You will also have to write the code for the evaluate method and display a message indicating whether or not the grid represents a Sudoku Sudoku v0.99 Sudoku va.99 File Help File Help 6 3 5 289 7 1 7 8 9 61 Figure 1 Figure 2

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Concepts

Authors: David M Kroenke, David J Auer

6th Edition

0132742926, 978-0132742924

More Books

Students also viewed these Databases questions