0
点赞
收藏
分享

微信扫一扫

159.234 OBJECT-ORIENTED PROGRAMMING S1, 2022

天蓝Sea 2022-04-16 阅读 58
pythonjava

159.234 OBJECT-ORIENTED PROGRAMMING                                                                        S1, 2022

Assignment 2

Deadline:

12 May 2022, 11pm

Evaluation:

40 marks (20% of your final grade)

Late Submission:

Deduct 5 marks per day late

Individual Work

You must complete this assignment by yourself (you must NOT share your code with others or use others’ code)

Purpose:

Reinforce Java OOP core concepts (abstraction, encapsulation, inheritance, and

polymorphism), collections framework and generics, exception handling, input and output streams, and unit testing

  1. System Description (Overview of Problem)

You are asked to write a program in Java to simulate a University Library System

Three types of items can be borrowed from the library—Books, Journals, and Movies. The library records each item’s type, ID, title, year, average rating, number of reviews, and maximum borrowing time (28 days for Books, 14 days for Journals, and 7 days for Movies). Furthermore, for books, the library must record author and number of pages; for movies, it must record director; and for journals, it must record volume and number. Due dates must be recorded for all items out on loan.

  1. Programming tasks to complete:
    1. Read text file library.txt (supplied); for each line in this file, create a Movie/Book/Journal object and add it to your ‘library’ object
    2. List all items in the library, but only display its ID, type, and title
    3. Prompt questions to allow users to do the following (refer to attached sample output at the end of this document for expected prompts and display details):
      1. Sort all the items first by average rating and then by ID
      2. Search items by ID or phrase in title, and list the items found
      3. Select an item from search results and display its details
      4. Borrow the selected item if it is available, and display new due date, or
      5. Return the selected item if it is on loan, or
      6. Rate the selected item and display new average rating
    4. Write JUnit test cases to check if your ‘search items by ID or phrase in title’ methods return correct results

  1. Functions workflow (related tasks are marked as A, B, C-a, C-b, C-d, C-d, C-e, and C-f):

quit

quit

Create and add library items to your system (A) and output all the items (B)

enter ‘id’

enter ‘phrase in title’           Restart       

search by

‘title’         

List the matching item (C-b)                  List all the matching items (C-b)

Selected the item

Selected one of the displayed items

restart

                                                                                                                                     

Display selected item details (C-c)

restart

if item is available

if item is on loan

restart

restart

Borrow or rate the item (C-d, C-f)

Return or rate the item (C-e, C-f)

restart

borrow

rate, enter rate value

return

rate, enter rate value

restart

Display item details after returned or rated (C-e, C-f)

Display item details after borrowed or rated (C-d, C-f)

Search by ‘id’ or ‘phrase in title’ (C-b)

Restart search by ‘id’

Sort all the items (first by average rating and then by id) (C-a)

Run your program

 

159.234 OBJECT-ORIENTED PROGRAMMING                                                                        S1, 2022

  1. Design and Implementation Guidelines

Note: You will receive credit for correctness, completeness, no code duplication, and clear on-screen outputs. Also, the following OOP and general software development guidelines will be checked while marking your program:

  1. Encapsulation design and implementation—proper use of modifiers
    1. Private/Protected/Public
    2. Must make use of getters and setters wherever appropriate.

  1. Inheritance design and implementation
    1. Reasonable class hierarchies
    2. Proper data-fields separation in base and derived classes
    3. Proper methods separation/overloading/overriding in base and derived classes
    4. Proper use of base and derived class constructors

  1. Polymorphism and implementation
    1. Write generic code that targets the base class whenever possible
    2. Appropriate use of overriding in derived classes to realize polymorphism

  1. Collections framework and generics
    1. Use ArrayList or another Java collection class to store information
    2. Implement Comparable/Comparator Interface(s) to sort items

  1. Exception handling
    1. Throw exceptions when an error occurs (e.g., an invalid piece of data is entered)
    2. Use “try/catch/finally” or “try/catch” block to handle exceptions

  1. Other Specifications

You must follow the next five specifications when completing this assignment:

  1. Create the method displayInfo to provide appropriate information as shown below. The content of displayInfo should be the first thing that displays onscreen

 

  1. Place appropriate comments in your program – e.g.:

/** explain what the program file is doing . . . */

// explain what a part/method of the program is doing…

  1. DO NOT add any file path for ‘library.txt’ (put it directly in your project folder when you test your code)
  2. DO NOT add your own package name(s) to the beginning of your .java file
  3. DO NOT use any function to clean the screen at any stage of your program

159.234 OBJECT-ORIENTED PROGRAMMING                                                                        S1, 2022

  1. Submission Requirements:

1) Zip all your source code (.java files) and submit as a single zip file to Stream

  1. Test data and sample outputs:

Task A: Input test data from library.txt file (supplied) into your system

 

Task B: List all items in the library

 

Record of movie: Type, ID, title, year, director

Record of book: Type, ID, title, year, author, number of pages

Record of journal: Type, ID, title, year, volume, number

159.234 OBJECT-ORIENTED PROGRAMMING                                                       

举报

相关推荐

0 条评论