Programming Homework Help

Puzzle Class NxNYourInitials & a ClientNxNYourInitials Java Programming Project

 

Task #3 Puzzle – Class NxNYourInitials and a ClientNxNYourInitials

Instance Variables:

  • n
  • array
    • 1 dim array (students who last name A-G)
    • 2 dim array (students who last name H-R)
    • an arrayList (students who last name S-Z)

Constructor: NxNYourInitials( int n ) creates an array with n2n2 elements AND filled with 1, 2, 3, . . . , n2n2. For example NxNYourInitials( 5 ) instantiate n = 5 and the arrays with 1, 2, 3, . . . 25.

Methods (recommended order): toString( ), printMe( ), addRow( int rr ), shake( ), addCol( int cc ), addDiag1(( ), addDiag2( ).You can use printMe( ) to check the other methods.

Client will instantiate an NxN puzzle and then solve it. Have a method to solve a 3×3 and another method to solve a 4×4. I will run them when grading your work.

Terminal example for a 3×3:

 2  9  4 
7 5 3
6 1 8
YOUR NAME GOT IT: 31230 tries, sum=15

Terminal example for a 4×4 (this run may take minutes to run):

 9  7 12  6 
16 2 13 3
5 11 8 10
4 14 1 15
YOUR NAME GOT IT: 1127660899 tries, sum=34