Java Encapsulation welcome challenge
Test 5 fails no matter how I set the variables. I've swapped the age variables in the setAge class from a to age and back again one by one and test 5 never passes no matter which way I try it. Is this a bug? import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner read = new Scanner(System.in); int a = read.nextInt(); Pupil pupil = new Pupil(); pupil.setAge(a); } } class Pupil{ private int age; //complete setter method public void setAge(int age){ if (age >= 6){ this.age = age; System.out.println("Welcome"); } else { System.out.println("Sorry"); } } public int getAge(){ return age; } }