D
D
Denis Kuznetsov2018-10-22 20:38:14
Java
Denis Kuznetsov, 2018-10-22 20:38:14

Why doesn't it go further through the body of the loop?

There is a check function in which many checks are performed

static void checkAll()
    {

        while (true)
        {
            StudentOrder sO = readStudentOrder();
            if (sO == null)
            {
                break;
            }
            AnswerCityRegister cityAnswer = checkCityRegister(sO);
            if (!cityAnswer.answer) // if answer is  then keep going
            {
                continue; // if it's empty than go to the beginning of cycle
            }
            AnswerWedding weddingAnswer = checkWedding(sO);
            AnswerChildren childAnswer = checkChildren(sO);
            AnswerStudent studentAnswer = checkStudent(sO);

            sendMail(sO);
        }
    }

one of these checks is
static AnswerCityRegister checkCityRegister (StudentOrder sO)
    {
        CityRegisterValidator cityRegisterValidator = new CityRegisterValidator();
        cityRegisterValidator.hostName = "Host1";
        cityRegisterValidator.password = "Password1";
        AnswerCityRegister answer = cityRegisterValidator.checkCityRegister(sO);
        return answer;
    }

it uses the class declared as
public class AnswerCityRegister
{
   public boolean answer;
}

same class
public class CityRegisterValidator
{
    public String hostName;
    public int port;
    private String login;
    public String password;

    public AnswerCityRegister checkCityRegister (StudentOrder sO)
    {

        System.out.println("CityRegister is running : " + hostName + ", " + login + ", " + password + '.');

        AnswerCityRegister ans = new AnswerCityRegister();
        ans.answer = false;
        return ans;
    }
}

after executing the code, outputs "CityRegister is running : " + hostName + ", " + login + ", " + password + '.' but in theory he had to carry out other checks and reach the end, what is stopping him?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Denis Zagaevsky, 2018-10-22
@DennisKingsman

ans.answer = false;
return ans;
so answer is always false. The if(!answer) check is always true.
continue; // if it's empty than go to the beginning of cycle
says it all.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question