Question

In: Computer Science

In Java: Suppose you want to implement a Sudoku game that consists of 9x9 rows and...

In Java: Suppose you want to implement a Sudoku game that consists of 9x9 rows and columns of squares. Which layout would be the best one to use and why? 2D Array or Grid Layout? If its a grid layout why would it be better to use?

Solutions

Expert Solution

In java, for to implement a Sudoku game that consists of 9x9 rows and columns of squares , GRID LAYOUT would be the best one to use because in sudoku ,the positioning of squares are very important and all squares should be of equal size which is provided by the GRID LAYOUT whereas in case of FLOW LAYOUT ,the positioning can't be guaranteed .If the box size increases then the extra box in that row is shifted to the next row which is not suitable for sudoku game

Comparing 2D array or GRID layout - GRID LAYOUT prevails because the programmer don't need to specifice the absolute co-ordinates for the elements instead the relative position are required so that the layout will calculate the absolute co-ordinates and it will be easy for the programmer to design.And , even when we resize we don't need to calculate everything .As,relative positions are already provided ,the layout will automatically calculate and place the elements accordingly which is not the case in 2d array


Related Solutions

• This lab, you will write a Java program to determine if a given Sudoku puzzle...
• This lab, you will write a Java program to determine if a given Sudoku puzzle is valid or not. • You determine if the puzzle is complete and valid, incomplete, or is invalid. • A puzzle is a 2-dimensional array 9x9 array. Each element contains the numbers 1 – 9. A space may also contain a 0 (zero), which means the spot is blank. • If you don’t know how a Sudoku Puzzle works, do some research, or download...
I WANT TO IMPLEMENT THIS IN JAVA PLEASE I want to create a small user input...
I WANT TO IMPLEMENT THIS IN JAVA PLEASE I want to create a small user input system for a university student, where they put the season and year of when they started their uni course. For example the system will ask "What year did you start your degree?", the user will input "Autumn/2022" as a string. Now from a string format as shown, it should take that user input and calculate for example +2 or +3 years to the date....
I WANT TO IMPLEMENT THIS IN JAVA PLEASE I want to create a small user input...
I WANT TO IMPLEMENT THIS IN JAVA PLEASE I want to create a small user input system for a university student, where they put the season and year of when they started their uni course. For example the system will ask "What year did you start your degree?", the user will input "Autumn/2022" as a string. Now from a string format as shown, it should take that user input and calculate for example +2 or +3 years to the date....
Suppose that you want to create a portfolio that consists of stock X and stock Y....
Suppose that you want to create a portfolio that consists of stock X and stock Y. For a​ $1,000 investment, the expected return for stock X is $ 71 and the expected return for stock Y is $ 102. The variance for stock X is 2,700 and the variance for stock Y is 8,625. The covariance of stock X and stock Y is 5,976. Complete parts​ (a) through​ (c). a.) Compute the portfolio expected return and portfolio risk if the...
Suppose that you want to create a portfolio that consists of a corporate bond​ fund, X,...
Suppose that you want to create a portfolio that consists of a corporate bond​ fund, X, and a common stock​ fund, Y. For a​ $1,000 investment, the expected return for X is $75 and the expected return for Y is $ 90 The variance for X is 1,725 and the variance for Y is 12,225. The covariance of X and Y is 4,583. a. The portfolio risk is ​$ b. Compute the portfolio expected return and portfolio risk if you...
In java, implement an animal guessing game. Start with a "Decision Tree", but present the leaves...
In java, implement an animal guessing game. Start with a "Decision Tree", but present the leaves as “Is it a X?” If it wasn't, ask the user what the animal was, and ask for a question that is true for that animal but false for X. For example, Is it a mammal? Y Does it have stripes? N Is it a pig? N I give up. What is it? A hamster Please give me a question that is true for...
/* *       Suppose we want to implement a class IntArraySet. The difference of this...
/* *       Suppose we want to implement a class IntArraySet. The difference of this class from IntArrayBag is that each item can only occur once in the set We will use the same instance variables. */ public class IntArraySet { private int[ ] data; private int manyItems; public IntArraySet() { this(10); } public IntArraySet(int initialCapacity) { if (initialCapacity < 0) throw new IllegalArgumentException ("The initialCapacity is negative: " + initialCapacity); data = new int[initialCapacity]; manyItems = 0; }...
Implement a method/function in java that produces running sum runningSum2DArray(int[][] array, int dir) across rows (left...
Implement a method/function in java that produces running sum runningSum2DArray(int[][] array, int dir) across rows (left to right or right to left) or columns (top to bottom or bottom to top) Input to the method: A 4x4 two dimensional int array and an integer (1, 2, 3 or 4 for left, right, up,down respectively). Output: The modified array after producing the running sums according to the direction. For example: If the input to the method is the same as the...
You pay $1 to play a game. The game consists of rolling a pair of dice....
You pay $1 to play a game. The game consists of rolling a pair of dice. If you observe a sum of 7 or 11 you receive $4. If not, you receive nothing. Compute the expected value and standard deviation for this game?
Java program that uses binary tree and recursions to implement Tower of Hanoi game where there...
Java program that uses binary tree and recursions to implement Tower of Hanoi game where there can be any amount of disks and there are either 3,4, or 5 pegs to store the disks(# of pegs and disks is manually inputted by user), in Tower of Hanoi game, the object of the game is move all the pieces from the 1st peg to the right most peg or the opposite side. You can place disks on top of each other...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT