0% found this document useful (0 votes)
3 views3 pages

Csii Proj s25

This programming project involves creating a library management system in Java, focusing on concepts like inheritance and polymorphism. Students will work in groups to implement classes for books and a library, allowing functionalities such as adding, removing, searching, and storing book information. The project requires submission of code files and a Word document with group details by May 1, 2025.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views3 pages

Csii Proj s25

This programming project involves creating a library management system in Java, focusing on concepts like inheritance and polymorphism. Students will work in groups to implement classes for books and a library, allowing functionalities such as adding, removing, searching, and storing book information. The project requires submission of code files and a Word document with group details by May 1, 2025.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Data Structures, Programming Project

Due Date: Thursday, May 1, 2025 Total Points: 30

Name: __________________ ID: ________________

Group Members:

Name: __________________ ID: ________________

Name: __________________ ID: ________________

This programming project can be done in groups of two or three students.

Write your Name and ID as shown above and the Names and ID numbers of your
group members.

Each student should upload this word document on Blackboard. However, only one
student in the group should upload the files that contain the Java code.

This project is about a library management system. It helps you to practice Inheritance,
Polymorphism, File and Exception handling in Java. It allows the user of your program to
manage a digital library, where he can add, remove, search, and store book information.

Define a Book class that serves as the base class. It should have a String title and
author. The Book class should have a constructor for initializing the title and
author. It should have a toString method that returns a string representation of the
Book object.

Define two subclasses, named EBook and PrintedBook. The EBook class should
have a fileSize, which is the size of the file in Megabytes.

The PrintedBook class should have the number of pages.

The EBook and PrintedBook classes should have constructors. They should override
the toString method and return a string representation of the EBook and
PrintedBook object that includes the title and author.

Define a Library class. It should use ArrayList<Book> books to store the list of
all books in the library. It should have the method addBook(Book b) for adding a
Book object, a boolean removeBook(title) method for removing a book with
given title that returns true if the book was found and removed,
searchBook(title) that returns a reference to the Book object with a specific
title, or null if the book was not found, displayBooks() that displays all the
books in the library (one book on each line), readFromFile(String pathname)
that reads all the books from a file (one book should be read on each line), and
writeToFile(String pathname) that saves all the books in a file (one book
should be written on each line).

To display an EBook, start with letter E followed by the title then comma(,) then
author then comma(,) then the book size. The comma (,) separates the data fields
as shown below:

E Digital Fundamentals, Floyd, 1.5 Mbytes

To display a PrintedBook, start with letter P followed by the title then comma(,)
then author then comma(,) then number of pages as shown below:

P Java Software Structures, Lewis and Chase, 662 pages

This is also how a book should be saved and read from a file. Each book should appear
on a separate line. Commas (,) are used to separate the data fields.

Write a displayMenu method that displays a menu to the user and returns his choice
as follows:

Library Management System Menu


------------------------------
1. Read all books from file
2. Add a new book
3. Remove a book
4. Search for a book
5. Display all books
6. Save to file and exit
------------------------------
Enter your choice (1 to 6):

If the user enters 1 for his menu choice, then ask the user to enter the pathname of the file
to read, for example:

Enter the pathname of the file to read: src/books.txt


If the user enters src/books.txt then you should read all the lines from this file into
the ArrayList. Each book should be read from a separate line. If the file does not
exist, you should display an error message on the screen and re-display the menu. For
example, your should create an EBook object for the first line that starts with E and a
PrintedBook object for the second line that starts with P. The data fields are separated
by commas (,) as shown below:

E Digital Fundamentals, Floyd, 1.5 Mbytes


P Java Software Structures, Lewis and Chase, 662 pages

The src/books.txt file should store one book on each line. Any number of books
can be stored in the file.

If the user enters 2 for his menu choice, then ask the user to enter the book type (E or P),
title, author, size or pages depending on the book type. Create a new EBook or
PrintedBook object, depending on the book type, and add it to the ArrayList
object.

If the user enters 3, then ask the user to enter the title of the book that should be
removed. If the book was found and removed then display “Book was removed”.
Otherwise, display “Book was not found”.

If the user enters 4, then ask the user to enter the title of the book. If the book was
found then display the book information. Otherwise, display “Book was not
found”.

If the user enters 5, then display all the books in the ArrayList object on the screen.
Each book should be displayed on a separate line.

If the user enters 6, then ask the user to enter the pathname of the file, save all books in
the ArrayList object in the file on the disk and terminate the execution of the
program. Each book should be written on a separate line inside the file.

Upload all your program classes on Blackboard. Make sure that your program compiles
and runs properly. Otherwise, you will lose all the points on correctness. I will NOT fix
your program if the code does not compile or run correctly.

You might also like