Too many 'if' statements?

前端 未结 26 1136
天涯浪人
天涯浪人 2020-11-30 16:24

The following code does work how I need it to, but it\'s ugly, excessive or a number of other things. I\'ve looked at formulas and attempted to write a few solutions, but I

26条回答
  •  借酒劲吻你
    2020-11-30 17:06

    You can create matrix which contains results

    int[][] results = {{0, 0, 1, 2}, {0, 0, 2, 1},{2, 1, 3, 3},{2, 1, 3, 3}};
    

    When you want to get value you will use

    public int fightMath(int one, int two) {
      return this.results[one][two]; 
    }
    

提交回复
热议问题