官术网_书友最值得收藏!

Implementation

The implementation of this specification is almost the same as the previous one. All we have to do is throw an exception if y does not fall within the defined range:

public void play(int x, int y) {
  if (x < 1 || x > 3) {
    throw new RuntimeException("X is outside board");
  } else if (y < 1 || y > 3) {
    throw new RuntimeException("Y is outside board");
  }
}

In order for the last test to pass, we had to add the else clause that checks whether Y is inside the board.

Let's do the last test for this requirement.

主站蜘蛛池模板: 台东市| 龙南县| 长子县| 郎溪县| 柯坪县| 蒙城县| 民和| 新密市| 泗阳县| 资中县| 诸暨市| 临高县| 买车| 商洛市| 将乐县| 桂阳县| 玉龙| 翁牛特旗| 鄢陵县| 措美县| 林甸县| 满洲里市| 绥芬河市| 商都县| 临海市| 宽城| 澄江县| 邛崃市| 利川市| 吉安市| 土默特右旗| 罗源县| 武安市| 庆元县| 东乡族自治县| 特克斯县| 曲水县| 南乐县| 留坝县| 太康县| 余庆县|