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

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.

主站蜘蛛池模板: 台湾省| 通化市| 汉中市| 宜春市| 张北县| 仁怀市| 康平县| 涡阳县| 山阳县| 霍城县| 铜陵市| 正阳县| 博湖县| 阜宁县| 公安县| 京山县| 和平县| 黄平县| 新疆| 邵阳市| 刚察县| 乌鲁木齐市| 鞍山市| 和顺县| 锦州市| 桃园县| 榕江县| 枣阳市| 察哈| 东安县| 贡山| 旺苍县| 四子王旗| 乐都县| 瑞昌市| 渭南市| 阜宁县| 乌拉特中旗| 拉萨市| 荥阳市| 永平县|