I am having some trouble getting a prompt to print out so a user can know what information to type. I have a student class that has a scanner as a constructor.
I also have a database class creates a menu for the user to pick the option to add a student to the array. Defining the addStudent method the menu calls is where I am having problems.
I can either get all the prompt's to print at once or not at all. If I include them in a loop I won't be able to get them to say different things.
Code:
public Person(Scanner in)
{
this.firstName = in.nextLine();
this.lastName = in.nextLine();
this.uid = in.next();
this.phone = in.next();
}
Code:
public Student(Scanner in)
{
super(in);
this.credits = in.nextInt();
this.points = in.nextInt();
}
Code:
public void addStudent()
{
if(records[numStudents] == null)
{
System.out.print("Enter the student's first name: ");
Scanner in = new Scanner(System.in);
records[numStudents] = new Student(in);
numStudents++;
}
else if(numStudents >= capacity)
{
System.out.println("The student database is full.");
}
}
Comment