You are on page 1of 3

LIBRARY SYSTEM

Designing and Implementation of Problem

Selected Data Structure and Algorithm Reasoning:


Array Data Structure is used to store the values from the file and Array of Objects to store the
object of the books which contains the strings of title, author, ISBN, and quantity named as qty as per
the requirements for the information of the book according to the library system.

The two types of arrays which are the main data structures to store the information in the program are
therefore:

 Array data structure named as “array” of length ten thousand.


 Array of Object data structure named as “book” of length ten thousand as well. This will help to
store the objects of the Book class which contains the strings as discussed above.

Now, let’s have discussion about the algorithm selected mainly to perform the required functionality
of the problem of Library System. The algorithm will be working as follows:

 First of all, a class names Book is created which is the main template to store the data regarding
books. This class contains books information including, title, author, ISBN and quantity of the
individual books. Further, a putBook method as setter to set the values of these entities. Also, a
getData method to get the information of the book having these entities.
 Now the given file for the books is read through the fstream library which will get the
information from the file. This information will be stored in an array data structure names as
“array” of size 10000 as discussed above.
 Further, an object of Book class is created which is actually array of objects named as “book” to
store the information about the books. The data is stored in these objects which is retrieved
from the array in which we have stored the information previously. This information is being
stored with the help of the putBook method by dividing the index of the “array” which has the
information from the file. All of the information is stored with the help of the for loop.
 Now a menu is displayed to the user which has the options regarding, search a book, add a
book, Remove a book, Exit. The user will have this menu to select and a switch is used to make
selections between what the user has selected.
LIBRARY SYSTEM

Testing of Implementation
Testing Approaches:
We will have both the functional and non-functional testing for the program as follows:

Functional Testing:
This will include what is the main functionality from the program. There are three main
functionalities which are to search, add or to remove the books. The test for the functionality will be as
follows:

 When user selects 1 which means to search a book then the title is required to enter as input
which must be present in the file so that program can search. The output will contain all of the
information regarding the book which has to be search.
 When selects 2 then it means new book has to be added then all of the information including
title, author, ISBN, quantity to be entered as input. Then message as result would be displayed
as --Record successfully added!—
 When user selects 3 then book may or may not be there so if book is not present then Record
not found! Would be displayed. On the other hand, if book is present in the record then
Element deleted successfully..!! will be displayed.
 If user want to exit then enter 4 to get exit from the program.

Non-Functional Testing:
This will cover the performance measure for the program of Library System. The worst-case time
complexity of the algorithm being used is O(n2) due to the selection made as to remove the book from
the records. Thus, quadratic time complexity will define the overall efficiency of the algorithm.

Further, the space complexity will be on the basis of what size of array is being considered to
store the information from the files and to store the objects of the Books.
LIBRARY SYSTEM

Table of Test Cases:


Test1 Test2 Test3 Test4 Test5
Choice 1 2 3 3 4
Title INPUT: Concepts in INPUT: INPUT: Concepts in ✖
Programming Advanced Concepts of Programming
Languages Mathematics Programs Languages
Author ✖ INPUT: John C. ✖ ✖ ✖
Luther
ISBN ✖ INPUT: ✖ ✖ ✖
23412394
Quantity ✖ INPUT: 3 ✖ ✖ ✖
Output Title: Concepts in --Record Record not Element deleted Main
Programming successfuly found! successfully..!! Menu will
Languages added!-- be
Author: Author: John displayed
C. Mitchell again by
ISBN: 9780521780988 selecting
Quantity: 1 exit

END

You might also like