Advertisement
Guest User

Untitled

a guest
Dec 14th, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.15 KB | None | 0 0
  1. /*
  2. * To change this license header, choose License Headers in Project Properties.
  3. * To change this template file, choose Tools | Templates
  4. * and open the template in the editor.
  5. */
  6. ////package magicsquare;
  7.  
  8. /**
  9. *
  10. * @author kelley
  11. */
  12. public class MagicSquare {
  13. //instance variable called data
  14. //should be a 2d array!
  15. //will hold the final state of the magicsquare
  16. //matrix
  17. int [][] data;
  18.  
  19. //should set data 2d array
  20. //should set data 2d array to
  21. //3x3 magicsquare
  22. //NO HARDCODING, Should be enerated by
  23. //computemagicSquare
  24.  
  25. //non-default constructor --> has param
  26. //accepts a size n for the ODD
  27.  
  28. public MagicSquare(){
  29. }
  30.  
  31. //non-default
  32. //accepts a size n for the ODD
  33.  
  34. public void computemagicsquare (int n){
  35. int [][] square = new int [n][n];
  36.  
  37. //Start number 1 in the top row, middle column.
  38. int row = n;
  39. int col = n/2;
  40.  
  41. int number = 1;
  42.  
  43. //Place consecutive integers in a diagonally-up-to-the-right pattern.
  44. row = row - 1;
  45. col = col + 1;
  46.  
  47. //Any number that goes outside the matrix above row 1
  48. //is moved to the bottom row.
  49. //n is the S I Z E
  50. if (row < 0){
  51. row = n - 1;
  52. }
  53. //Any number that goes outside the matrix past the
  54. //right column is moved to the left column.
  55. if (col < 0){
  56. col = n - 1;
  57. }
  58.  
  59. //Any number, which follows the multiple of the matrix size
  60. //is moved down 1 row.
  61. if (jklfjdklajfadkl;jdas;%n = 0){
  62. row = n - 1;
  63. }
  64. }
  65.  
  66.  
  67. public void getData(){
  68. return array;
  69. }
  70.  
  71. public boolean checkRows(int[][] arr){
  72.  
  73. }
  74.  
  75. public boolean checkColumns(int[][] arr){
  76.  
  77. }
  78.  
  79. public boolean checkDiagonals(int[][] arr){
  80.  
  81. }
  82.  
  83. public void displayMagicSquare(int[][] arr){
  84.  
  85. }
  86.  
  87. public void checkMagicSquare(int[][] arr){
  88.  
  89. }
  90.  
  91.  
  92. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement