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

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.

主站蜘蛛池模板: 垦利县| 平昌县| 灵山县| 平阳县| 鞍山市| 五原县| 罗城| 太原市| 四川省| 桐乡市| 易门县| 巴南区| 郎溪县| 鄂托克前旗| 社旗县| 高密市| 怀化市| 大姚县| 凌海市| 临颍县| 广南县| 刚察县| 连云港市| 亚东县| 泾源县| 盐亭县| 沈阳市| 行唐县| 太湖县| 益阳市| 平乐县| 聂拉木县| 治县。| 新密市| 凭祥市| 佛坪县| 噶尔县| 城口县| 东海县| 凌源市| 隆化县|