Post on 13-Dec-2015
Programming Fundamentals I
Java Programming Spring 2009
Instructor: Xuan Tung Hoangtung_hx@icu.ac.kr
TA: Tran Minh Trungtrungtm@icu.ac.kt
Lab guide #5
XuanTung Hoang 2
LibMan - ProjectBookRec class-Title: String-ID: Int-Ammount: Int-Available: Int+setTitle(String title): void+getTitle(): String+setID(int ID): void+getID():int+setAmount(int anAmount):void+getAmmount():int+update(int n): void+getnAvailable():int
LibMan class-libTitle: String-nBookshelves: Int-books: BookRecs+setTitle(String title): void+getTitle(): String+setnBookshelves (int n): void+getnBookshelves ():int+showLibInfo():void+addNewBook():void+placeBooktoBookshelf(int bookshefID,BookRec bRec): void+bookStatus(int bookID):boolean+borrowBook(int bookID):void+returnBook(int bookID):void
N 1
1 1
TestLibMan-option: int+main():void+showMenu():void+askOption():void
XuanTung Hoang 3
LibMan – new functions addNewBook()
Add new book bookStatus(bookID)
Available: Retuns true, Print out Title, # of books left
Otherwise: Return false
borrowBook(bookID) Check if the book is available or not If available then borrow, and update the # of books
left Show again the updated status
returnBook(bookID) Update the # books left Show again the updated status
XuanTung Hoang 4
LibMan – Template & requirements Links:
http://wine.icu.ac.kr/ice0124/lab5/BookRec.java http://wine.icu.ac.kr/ice0124/lab5/LibMan.java http://wine.icu.ac.kr/ice0124/lab5/
TestLibMan.java Requirements
Understand problem Understand the structure of template code Complete missed codes (fill in … area)
Note: You can design your own program for solving the problem
XuanTung Hoang 5
Templates & output examples TestLibMan.java
C:\java TestLibMan========== Main menu ========1. Show library information2. Add new book3. Show book's status4. Borrow a book5. Return a book==============================Enter menu ID (1-5):
XuanTung Hoang 6
addNewBook()
2. Add new book-----------------------------Enter book's information:(1)Possition: 1(2)(2) ID: 1(3) Amount: 20(4) Title: Java tutorial 2009
XuanTung Hoang 7
bookStatus(bookID)
3. Show book's status-----------------------------Enter book's ID: 1Book title: Java tutorial 2009Bookshelf ID: 1Total amount: 20Left amount: 20
3. Show book's status-----------------------------Enter book's ID: 1Book title: Java tutorial 2009Bookshelf ID: 1Total amount: 20Left amount: 20
XuanTung Hoang 8
borrowBook(bookID)
4. Borrow a book-----------------------------Enter book's ID: 1Book title: Java tutorial 2009Bookshelf ID: 1Total amount: 20Left amount: 20
The book is borrowed successfully!Book title: Java tutorial 2009Bookshelf ID: 1Total amount: 20Left amount: 19
XuanTung Hoang 9
returnBook(bookID)
5. Return a book-----------------------------Enter book's ID: 1
The book is returned successfully!Book title: Java tutorial 2009Bookshelf ID: 1Total amount: 20Left amount: 20
XuanTung Hoang 10
Submission and Report Due: Right after lab time Compress your source/class files into a ZIP
file Name the zip file according with the following
template: StudentID_labNumber.zip
Example: 20091004_lab4.zip
Submit the file to TA Email address: submit.hw.code@gmail.com Subject: “StudentID_ICE0124_lab4”
Example: 20061004_ICE0124_lab4