jeudi 29 avril 2021

Why is my if statement just skipping past the first part?

This code is meant to output the doctor's name and specs, but it is skipping this and just outputting that it is not available

    private void listDoctors()
{
   //Zachary Thompson 23/04/2021 List all the doctors and their information 
       if(doctor1!=null)
   {
        System.out.println("Doctor 1 = ");
        System.out.println(doctor1.getName());
        System.out.println(doctor1.getSpecialisation());
    }
   else 
   {
       System.out.println("Doctor 1 is not available");
    }
   if(doctor2!=null)
   {
        System.out.println("Doctor 2 = ");
        System.out.println(doctor2.getName());
        System.out.println(doctor2.getSpecialisation());
    }
   else System.out.println("Doctor 2 is not available");
}

Aucun commentaire:

Enregistrer un commentaire