I have to do a project for my Computer Science class. The problem is:
Patrons of a library can borrow up to three books. A patron, therefore, has a name and up to three books. A book has an author and a title. Design and implement two classes, Patron and Book, to represent these objects and the following behavior:
- The client can instantiate a book with a title and author
- The client can examine but not modify a book's title or author
- The client can ask a patron wthere it has borrowed a given book (identified by title).
- The client can tell a patron to return a given book (identified by title).
- The client can tell a patron to borrow a given book.
The Patron class should use a seperate instance variable for each book (a total of three). Each of these variables is initially null. When a book is borrowed, the patron looks for a variable that is not null. If no such variable is found, the method returns false. If a null variable is found, it is reset to the new book and the method returns true. Similar considerations apply to other methods. Use the method aString.equals(aString) to compare two strings for equality. Be sure to include appropriate toString methods for your classes and test them with a tester program.
Here is my Client
class, which contains the main
method: http://pastebin.com/JpxCT2F6
Now my problem is that when I run the program, the program doesn't wait for user input. Here is what comes up in the console of Eclipse:
Please enter title of book 1:
s
Please enter author of book 1:
e
Please enter title of book 2:
f
Please enter author of book 2:
t
Please enter title of book 3:
g
Please enter author of book 3:
d
Which book would you like to check for?
s
The patron has taken out the book s
Would you like to return a book? (1 yes or 2 no)
1
Which book would you like to return?
Sorry, could not find the book
Would you like to take out a book? (1 yes or 2 no)
2
Invalid option
Which book would you like to check for?
The patron does not have taken out
Would you like to return a book? (1 yes or 2 no)
Ass you can see, the console doesn't wait for user input after "Which book would you like return?" Instead, it takes a blank value. And later in the code, i put in "2", which means to return no book, but instead gives me an invalid input output.