(10 pts) For each of these pieces of data, would you use a single-dimensional array, a multi-dimensional array, or not use an array?
(a) A deck of cards (b) A Bingo sheet
(c) A list of car names (d) A String
(e) A Battleship game board
(15 pts) Two arrays, list1 and list2, are strictly identical if and only if all of their corresponding contents are equal- eg they contain the same elements in the same order. Write a method that returns true if two given lists are strictly identical using the following header:
public static boolean equals(int [] list1 , int [] list2 )
Write a test program that prompts the user to enter two lists of integers and displays whether the two are
identical. Hint: prompt the user to enter the length of each list first, then the list itself.
(25 pts) Write a method for checking whether a game of tic-tac-toe has been won by a particular player. The method takes as arguments the current board as a character matrix and which character to check, as shown by the method header below. It returns true if the player for that character has won- eg if that character is in all three places in a row, a column, or a diagonal.
public static boolean won(int[][] board, char which)
Write a test program that allows a user to input a potential tic-tac-toe solution as ‘X’ and ‘O’ characters and
checks and prints whether X has won and whether O has won.
You may also use the following method to draw the board to the console:
10 }
1.
2.
1
3.
1
//method for drawing a tic−tac−toe board public static void drawBoard(char [ ] [ ] board) {
1
2
3
4
5
6
7}
8 S y s t e m . o u t . p r i n t l n ( “ n −−−−− ” ) ; 9}
S y s t e m . o u t . p r i n t l n ( “−−−−−” ) ;
for ( int i =0; i
Uncategorized
(10 pts) For each of these pieces of data, would you use a single-dimensional ar
- Posted
- AuthoradminX
- Length312 words
- Reading time2 min
Make your next academic task easier to manage
Tell us what you are working on and take the next step with Treatisely.