This is where i put a user in the array
public void addUser(int choice)
{
if(choice==1)
{
System.out.println("Please enter your first name " );
String fName = input.next();
System.out.println("Please enter your last name " );
String lName = input.next();
System.out.println("Please enter your title " );
String title = input.next();
System.out.println("Please enter your date of birth " );
String birthDate = input.next();
System.out.println("Please enter your home address " );
String homeAddress = input.next();
System.out.println("Please enter your phone number " );
String phoneNumber = input.next();
System.out.println("Please enter your Library card barcode " );
int barCode = input.nextInt();
System.out.println("Please enter your Student ID " );
String studentId = input.next();
StudentBorrower studentBor = new StudentBorrower(fName, lName, title, birthDate, homeAddress, phoneNumber, barCode, studentId);
int x=0;
libraryUsers[x]=studentBor;
x++;
}
I was thinking that i might need a loop, but then wouldnt this limit the users choice when they want to enter their details? Like with a loop, they couldnt enter details, check contents, enter more details, check contents, etc
so i am not too sure if i am doing the incrementing ok at the bottom of that method.
The printing out method is like so
public void getBorrowers()
{
for(int x=0; x<libraryUsers.length; x++)
{
System.out.println(libraryUsers[x].toString());
}
}
I cant really see anything wrong with this, so i am thinking its the way i am adding items to my array in my first method. Any advise would be great

New Topic/Question
Reply




MultiQuote





|