Starting from:

$25

OOP - Online library system  - Solved

Using classes and arrays, the team will develop a set of functions for online library system. A system is represented by the following structure:

 

class UserList (7 marks) 

{     private: 

        User* users;         int capacity;         int usersCount; 

 

    public: 

        UserList(int capacity);         void addUser(User user); // at the end of the array. 

        User& searchUser(string name); 

        User& searchUser(int id);         void deleteUser(int id); 

         friend ostream &operator<<( ostream &output, UserList &userList )//to display all books 

        ~UserList(); 

}; 

 

 

class BookList (10 marks) 

{     private: 

        Book* books;          int capacity;          int booksCount;     public: 

        BookList(const BookList& anotherList); 

        BookList(int capacity); 

        Book& searchBook(string name); 

        Book& searchBook(int id); 
 
 
        void deleteBook(int id); //delete a book  

        Book getTheHighestRatedBook(); 

        Book* getBooksForUser(User); // get all books of this author 

        Book & operator [ ] (int position);           friend ostream &operator<<( ostream &output, BookList &booklist ); //to display all books          ~BookList(); 

        

}; 

 

//Note: when you delete a book, the book could be in the middle of the array, which will leave a gap in your array of books. You should fill the gap by shifting all the books to the right of the deleted book one place to the left. 

The same scenario should happen when deleting a user. 

 

 
 
 
 
B1 id=1 
B2 id=2 
B3 id=3 
B4 id=4 
B5 id=5 
 
 
                  deleteBook(2) 

 
 
 
 
 

B1 id=1 
B3 id=3 
B4 id=4 
B5 id=5 
 
  

Task 2 (3 Marks) 
-         Team should write a demo program to demonstrate the use of these functions.

-         Team should test the entire program and make sure that it works correctly in full.

-         All team members must fully understand all parts of the program.

 

Task 3 - Writing Good Quality Code 
No program stays the same. It will need to change to fix bugs, add new features, etc. So, it is very important to write high quality readable code, so that you or other developers can be able to review and modify this code in the future. In this task, you will:

 

1-   Add a header to your program saying who the author is, the purpose of the program, etc.

2-   Add a header for every function explaining what it does, what parameters it takes and what value it returns.

3-   Write the code following C++ coding style. http://geosoft.no/development/cppstyle.html 

4-   Add comments to any part that is difficult to understand

More products