布尔值不会延续到下一行?

时间:2015-03-08 13:10:41

标签: java

我刚要完成我制作的一个程序,但我遇到了一个问题。我有一个名为'mayWater'的布尔值,但它不会延续到程序的下一部分,即'pulic void result'行。在这里。

private boolean mayWater(String userMonth, String userDay, String userGroup) {

    boolean outcome = false;
    switch (userMonth)

    {
    //True statements go here

    default:
        outcome = false;
        break;

    }
    return outcome;
}


public void result(String userGroup, String userMonth, String userDay) {

    System.out.println("The group you mentioned earlier was Group : "
            + userGroup + ".");
    System.out.println("You wished to water on a " + userDay
            + " in the month of " + userMonth + ".");
//This below line was my problem    
if (mayWater()) 

It was then changed to the following:

    if (mayWater(String userGroup, String userMonth, String userDay))

2 个答案:

答案 0 :(得分:1)

canWater是一个包含3个参数的方法 - canWater(String userMonth, String userDay, String userGroup)

你不能在没有参数的情况下调用它。

这样称呼:

if (canWater(userMonth, userDay, userGroup)) {
    ...
}

答案 1 :(得分:1)

您的canWater方法需要三个参数,而您没有传递这三个参数。

您需要将三个参数传递给canWater方法,例如:

if (canWater(userMonth, userDay, userGroup)) {