In this exercise, you will extend the Java program that we developed in class for the Library to accommodate multiple copies of each book. Start by downloading the java files containing the Book and Library class files that we developed in class from the same page that you normally get the notes from (here).
Next, modify the Book class, but DO NOT modify the Library class! Your goal is to implement the new capability without making any changes at all to the Library class. Start by changing the boolean variable called "available" to an int that represents the number of available copies. Next, modify the Book constructor to represent the presence of two copies of each book that is created. Next, modify the checkIn, checkOut, and getAvailable classes to check and/or update the available variable appropriately. Note that the getAvailable method must still return a boolean, since we want NO CHANGES AT ALL to the Library class. You may change the main method in the in the Book class to see if everything is working okay if you like.
Then run the main method in the Library class (NOT the Book Class). If it prints "Darn, it's still available!", then your program is operating correctly. If not, go back and look again at the Book class to figure out what you did wrong. If you find problems that you can't fix, attend the lab session to seek help from the TA, or send one of us an email with enough details so that we can help. Plan ahead: because of overseas travel, I may not be on email much more than once a day in the next week, and I may not be on at all on Sunday!
Finally, export your revised Book.java file and email it as an attachment to both the TA and me (to ensure that one of us gets it). Email submitted after the deadline (Monday at 5:30) will not be graded (since the solutions will be posted), so it is a sure thing that you would be better off to send something on time rather than to sending nothing in the hopes that you might have something better later. And you would be MUCH better off to attend class on Monday than to skip it so that you can work more on your homework (since you would get a zero on the homework AND miss the class - a really bad deal). Anyhow, you won't know how generous we will be with partial credit until you try! Be sure to read the instructions about working together on homework on the course description Web page if you have any questions about what sort of collaboration is allowed.