Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package jp.starfree.cpsv;
- /*
- * FieldClass
- * @author CreeperSaviour
- * @version 0.0.1
- */
- public class Field {
- private int width, height;
- private final char[][] field;
- /*
- * 10 * 10 のFieldをインスタンス化する
- * @since 0.0.1
- */
- Field() {
- this.width = 10;
- this.height = 10;
- this.field = new char[this.width][this.height];
- for(var i = 0; i < this.width; i += 1) {
- for(var j = 0; j < this.height; j += 1) {
- this.field[i][j] = ' ';
- }
- }
- }
- /*
- * width * height のFieldをインスタンス化する
- * @since 0.0.1
- * @param width 幅
- * @param height 高さ
- */
- Field(int width, int height) {
- if(width != height) {
- try { throw new Exception("Failed Instantiating.");
- } catch (Exception e) { }
- System.exit(-1);
- }
- this.width = width;
- this.height = height;
- this.field = new char[this.width][this.height];
- for(var i = 0; i < this.width; i += 1) {
- for(var j = 0; j < this.height; j += 1) {
- this.field[i][j] = ' ';
- }
- }
- }
- /*
- * 引数のfieldをもとにFieldをインスタンス化する
- * @since 0.0.1
- * @param field フィールド
- */
- Field(char[][] field) {
- this.field = field;
- }
- /*
- * widthを返す
- * @since 0.0.1
- * @return width
- */
- public int getWidth() {
- return this.width;
- }
- /*
- * heightを返す
- * @since 0.0.1
- * @return height
- */
- public int getHeight() {
- return this.height;
- }
- /*
- * 左からwidth番目、上からheight番目においての文字を返す
- * @since 0.0.1
- * @param width 幅
- * 壁も含める
- * @param height 高さ
- * 壁も含める
- * @return 失敗したら@
- */
- public char getSquare(int width, int height) {
- return '@';
- }
- /*
- * フィールドに左からwidth番目、上からheight番目においての文字を入れる
- * @since 0.0.1
- * @param width 幅
- * @param height 高さ
- * @param type 種類
- * @return 成功したらtrue, 失敗したらfalse
- */
- public boolean setSquare(int width, int height, String type) {
- return false;
- }
- /*
- * フィールドの取得
- * @since 0.0.1
- * @return Field型のフィールド
- */
- public Field getField() {
- return new Field(this.field);
- }
- /*
- * フィールドの取得
- * @since 0.0.1
- * @return char[][]型のフィールド
- */
- public char[][] toCharArray() {
- return this.field;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement