1 / 4

Programming Fundamentals I Java Programming Spring 2009

Programming Fundamentals I Java Programming Spring 2009. Instructor: Xuan Tung Hoang tung_hx@icu.ac.kr TA: Tran Minh Trung trungtm@icu.ac.kt. Homework#4. Homework #4 (1): Encapsulation. Write a class, BookRec , to manage book’s information. Class BookRec contains:

melita
Download Presentation

Programming Fundamentals I Java Programming Spring 2009

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Programming Fundamentals IJava Programming Spring 2009 Instructor: Xuan Tung Hoang tung_hx@icu.ac.kr TA: Tran Minh Trung trungtm@icu.ac.kt Homework#4

  2. Homework #4 (1): Encapsulation • Write a class, BookRec, to manage book’s information. Class BookRec contains: • Properties (Instance variables): • title: String (title of a book) • id: int (identifier of a book) • amount: int ( number of copies of a book ) • Constructors • BookRec(String atitle, int anId, int anAmount) • BookRec(String atitle, int anId) • BookRec(BookRec aBookRec) • Set/Get methods for all above properties • getTitle(): String • setTitle( title: String ) • …

  3. Homework #4 (2): Composition • Write a LibMan class that contains • A list of book records (array) • BookRec[] books • A constructor • LibMan(nBooks: int) • nBook is the number of book records that are managed • set methods: • void setBook(int pos, BookRec bRec ) • This method places a book record bRec in array books of LibMan at position pos • Get methods: • BookRec getBook(int pos) • This method gets a BookRec object at position pos from array books • BookRec getBookByID(int bookID) • This method searches a book record (in array books) whose idmatches bookID. If a book record is found, return it. Otherwise, return null.

  4. Submission and Report • Due: 24th April, mid-night • 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

More Related