Square - import java.util.Random; / for Random Class public...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
import java.util.Random; // for Random Class i public class Square { // Á¤ÀÇ µÇ¾î ÀÖ´Â ¸â¹ö º¯¼ö¸¸ »ç¿ëÇÒ °Í // Only use follow variable // don't declare the other variable private int size; private int[][] arrar; p // Constructor method // Allocate array in memory area with parameter size // Generally, instance variable is initialized in constructor method public Square(int size) { this.size = size; arrar = new int[size][size]; a for (int i = 0; i < size; i++) { for (int j = 0; j < size; j++) { arrar[i][j] = 0; } } } // setValue() method // set the value to the arrar[row][col] public void setValue(int row, int col, int value) { arrar[row][col] = value; } // getValue() method // return value of squareBox[row][col] public int getValue(int row, int col) { return arrar[row][col]; } // getSize() method // return the size of Square public int getSize() { return size; } // printSquare() method // ´ÙÀ½ Æ÷¸Ë°ú ó·³ Ãâ·ÂÇÏ´Â ÇÔ¼ö ÀÛ¼º // print the each members in the array as follows: // ex) size is 3 // [12] [34] [23] // [24] [25] [67] // [56] [43] [87] public void printSquare() { for (int i = 0; i < size; i++) { for (int j = 0; j < size; j++) { System.out.print("[" + arrar[i][j] + "]\t"); } System.out.println(); } } // createDirtySquare() method
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
// Square ¿ÀºêÁ§Æ®¸¦ »ý¼º ÈÄ // 1ºÎÅÍ n^2±îÁöÀÇ ¼ö¸¦ ·£´ýÇÏ°Ô ¹è¿ÇÔ (Áߺ¹ Çã¿ë)
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 4

Square - import java.util.Random; / for Random Class public...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online