159.234 java核心解析

波光粼粼
• 阅读 516

159.234 OBJECT-ORIENTED PROGRAMMING S1, 2023
Assignment 2
Deadline: 11 May 2023, 11pm
Evaluation: 40 marks (15% 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 including the code generated by Artificial
Intelligence platforms such as ChatGPT)
Purpose: Reinforce Java OOP core concepts (abstraction, encapsulation, inheritance, and
polymorphism), collections framework and generics, exception handling, and
input and output streams.

  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.
  2. Programming tasks to complete:
    A. 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
    B. List all items in the library, but only display its ID, type, and title
    C. 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):
    a. Sort all the items first by average rating and then by ID
    b. Search items by ID or phrase in title, and list the items found
    c. Select an item from search results and display its details
    d. Borrow the selected item if it is available, and display new due date, or
    e. Return the selected item if it is on loan, or
    f. Rate the selected item and display new average rating
  3. Functions workflow (related tasks are marked as A, B, C-a, C-b, C-d, C-d, C-e, and C-f):
    Run your program
    Create and add library items to your system (A) and output all the items (B)
    Search by ‘id’ or ‘phrase in title’ (C-b)
    quit
    enter ‘id’
    Display selected item details (C-c)
    Borrow or rate the item (C-d, C-f) Return or rate the item (C-e, C-f)
    if item is available if item is on loan
    Display item details after borrowed or rated
    (C-d, C-f)
    borrow rate, enter rate value
    Display item details after returned or rated
    (C-e, C-f)
    return rate, enter rate value
    restart
    restart
    restart restart
    List the matching item (C-b)
    Selected the item
    title’
    enter ‘phrase in title’
    List all the matching items (C-b)
    Selected one of the displayed items
    title’
    restart
    restart
    Restart
    search by
    ‘title’
    Restart
    search
    by ‘id’
    Sort all the
    items (first by
    average rating
    and then by id)
    (C-a)
    quit
    2
    159.234 OBJECT-ORIENTED PROGRAMMING S1, 2023
  4. 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
    a. Private/Protected/Public
    b. Must make use of getters and setters wherever appropriate.
    2) Inheritance design and implementation
    a. Reasonable class hierarchies
    b. Proper data-fields separation in base and derived classes
    c. Proper methods separation/overloading/overriding in base and derived classes
    d. Proper use of base and derived class constructors
    3) Polymorphism and implementation
    a. Write generic code that targets the base class whenever possible
    b. Appropriate use of overriding in derived classes to realize polymorphism
    4) Collections framework and generics
    a. Use ArrayList or another Java collection class to store information
    b. Implement Comparable/Comparator Interface(s) to sort items
    5) Exception handling
    a. Throw exceptions when an error occurs (e.g., an invalid piece of data is entered)
    b. Use “try/catch/finally” or “try/catch” block to handle exceptions
  5. 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
    2) 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…
    3) DO NOT add any file path for ‘library.txt’ (put it directly in your project folder when you test your
    code)
    4) DO NOT add your own package name(s) to the beginning of your .java file
    5) DO NOT use any function to clean the screen at any stage of your program
    3
    159.234 OBJECT-ORIENTED PROGRAMMING S1, 2023
  6. Submission Requirements:
    1) Zip all your source code (.java files) and submit as a single zip file to Stream
  7. Test data and sample outputs:
    WX:codehelp
点赞
收藏
评论区
推荐文章
blmius blmius
4年前
MySQL:[Err] 1292 - Incorrect datetime value: ‘0000-00-00 00:00:00‘ for column ‘CREATE_TIME‘ at row 1
文章目录问题用navicat导入数据时,报错:原因这是因为当前的MySQL不支持datetime为0的情况。解决修改sql\mode:sql\mode:SQLMode定义了MySQL应支持的SQL语法、数据校验等,这样可以更容易地在不同的环境中使用MySQL。全局s
美凌格栋栋酱 美凌格栋栋酱
7个月前
Oracle 分组与拼接字符串同时使用
SELECTT.,ROWNUMIDFROM(SELECTT.EMPLID,T.NAME,T.BU,T.REALDEPART,T.FORMATDATE,SUM(T.S0)S0,MAX(UPDATETIME)CREATETIME,LISTAGG(TOCHAR(
待兔 待兔
1年前
手写Java HashMap源码
HashMap的使用教程HashMap的使用教程HashMap的使用教程HashMap的使用教程HashMap的使用教程22
梦
4年前
微信小程序new Date()转换时间异常问题
微信小程序苹果手机页面上显示时间异常,安卓机正常问题image(https://imghelloworld.osscnbeijing.aliyuncs.com/imgs/b691e1230e2f15efbd81fe11ef734d4f.png)错误代码vardate'2021030617:00:00'vardateT
Wesley13 Wesley13
3年前
MySQL 的慢 SQL 怎么优化?
!(https://oscimg.oschina.net/oscnet/7b00ec583b5e42cc80e8c56c6556c082.jpg)Java技术栈www.javastack.cn关注阅读更多优质文章(https://www.oschina.net/action/GoToLink?urlhttp
可莉 可莉
3年前
2021年全球公有云终端用户支出将增长18% ;EMNLP 2020最佳论文:无声语音的数字发声
!(https://static001.geekbang.org/infoq/af/af9f6637b50b09be60b00a42f3812d5e.png)开发者社区技术周刊又和大家见面
Stella981 Stella981
3年前
2021年全球公有云终端用户支出将增长18% ;EMNLP 2020最佳论文:无声语音的数字发声
!(https://static001.geekbang.org/infoq/af/af9f6637b50b09be60b00a42f3812d5e.png)开发者社区技术周刊又和大家见面
Stella981 Stella981
3年前
OpenJDK11与Spring Cloud Finchley的不兼容问题与解决
本文的环境:OpenJDK11.0.4,SpringCloudfinchleySR4,SpringBoot2.0.3最近遇到了一个问题,在feign调用的时候,时常会出现这样一个奇怪的错误:2019100708:00:00.620ERRORxxx,e1ba4c7540954aa3,871b99c4576d42e3
Stella981 Stella981
3年前
QClub 太原,2014年11月15日 Global Day of Coderetreat
QClub太原,2014年11月15日GlobalDayofCoderetreat活动时间:2014年11月15日星期六,全天(9:0018:00)活动地点:高新区体育路科技街口,大豪益达402(从KK这边的巷子进去,统一这面
Stella981 Stella981
3年前
Eureka Server 开启Spring Security Basic认证
!Desktop(https://uploadimages.jianshu.io/upload_images/98242475ce94f98ae00f42f.jpg?imageMogr2/autoorient/strip%7CimageView2/2/w/1240)文章共503字,阅读大约需要2分钟!概述
Stella981 Stella981
3年前
AI 科学家带你快速 Get 人工智能最热技术
!(https://pic3.zhimg.com/80/v2af9f6637b50b09be60b00a42f3812d5e_1440w.jpg)日前,京东智联云与贪心学院联合举办的人工智能前沿技