我想看看用户输入是否匹配数组的任何元素

时间:2019-08-09 17:40:13

标签: java

所以我想查看我的用户输入是否匹配数组中的任何值,如果是,则将长度设置为3.7。

代码是atm的样子:

 public Dog(String regName, String regBreed, int regAge, int regWeight){
        name = regName;
        breed = regBreed;
        age = regAge;
        weight = regWeight;


    }
    public double getTailLength() {
        String[] tailArray = {"Tax", "Dachshund", "tax", "dachshund"};
        boolean found = false;
        if (tailArray.equals(breed)){
        found = true;
        }
        if (found) {
            length = 3.7;
        }
        else {
            length =  (double) age *  weight / 10.0;
        }
        return length;

    }

不幸的是,关于如何使它起作用的任何想法都没有奏效吗?

0 个答案:

没有答案