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

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.

主站蜘蛛池模板: 永城市| 内江市| 东乌| 彭泽县| 绥滨县| 武定县| 吉首市| 东乌珠穆沁旗| 青阳县| 巴楚县| 宜丰县| 阳原县| 加查县| 航空| 诸城市| 台北县| 湘西| 民县| 焉耆| 游戏| 随州市| 馆陶县| 白城市| 应城市| 亚东县| 江门市| 观塘区| 乐亭县| 普兰店市| 兰考县| 新田县| 昆山市| 定远县| 平邑县| 上思县| 西峡县| 寿阳县| 同德县| 云南省| 梁山县| 尚义县|