Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

please someone help with the question (b) Write a command line game with the following functionality: The application should prompt the user for an odd

image text in transcribed

please someone help with the question

(b) Write a command line game with the following functionality: The application should prompt the user for an odd integer and create a magic square of that size. The magic square should then be shuffled by repeatedly (for n^2(n square) times) choosing a random element and swapping it with a random neighbour (not including diagonals). The shuffled square should be displayed to the user, who must attempt to reconstruct a magic square. The user makes moves by giving input of the form:

i j direction

where i and j specify the row and column of an element to be swapped, and direction (either U, D ,L ,R representing up, down, lef t and right) specifies which direction it should be swapped with. For example, the move 2 1 D applied to the square above would give:

6 1 8 2 5 3 7 9 4

On completion, the game should report the number of moves made. (18 Marks) [Functionality: 5, Design: 10, Ease of use: 2, Presentation: 1

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------

HINT: MULTIDIMENSIONAL ARRAYS The code below gives an example of using a 2-dimensional array to store values:

public class MultiArrayTest { public static void main ( String [] args ) { int a [][] = {{1 ,2 ,3} , {4 ,5 ,6}}; System . out . println ( " length of a is " + a . length ) ; for (int i = 0; i b) Write a command line game with the following functionality The application should prompt the far an odd integer and create a muugi apanee of that si . The magic aquare sul than bersed by repeatedly for a tim) doing a radices comment and wrapping it with a random sarighborar (not including diagonal . The herald be play to the wat, what itempt to matract a magie The member by giving input of the form: i direction where i adj pecify the one and column of bent to be apped, and direction (either U, D 1. Repeating down, left and right) pecife which dictions it all be apped with. For camps, the mwe 21 Dupplied to the care bere would give On completion, the game bald report trumber of aw made. (18 Mark) [Functionality: S, Design: 10, E. of: 2, Prementation: 1 HINT: MULTIDIMENSIONAL ARRAYS The code below you an emple using a 2-dimensional arwy to ste vulas public class MultiArrayTeat public static void main(String[] args) { int (0) - (11.2.3). [4,5,6}); System.out.println("length of as a length); for (int i = 0; i

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

DNA Databases

Authors: Stefan Kiesbye

1st Edition

0737758910, 978-0737758917

More Books

Students also viewed these Databases questions

Question

internationalization of business?

Answered: 1 week ago