Introduction In this lab, we will use class to design a library management system. In the library management system, we

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899604
Joined: Mon Aug 02, 2021 8:13 am

Introduction In this lab, we will use class to design a library management system. In the library management system, we

Post by answerhappygod »

Introduction In This Lab We Will Use Class To Design A Library Management System In The Library Management System We 1
Introduction In This Lab We Will Use Class To Design A Library Management System In The Library Management System We 1 (33.72 KiB) Viewed 47 times
Please use c++ to do it!!!!!!!!!!!!!!
include "Book.h"
#include <iostream>
#include <cstring>
using namespace std;
/*
* Task 1: Constructor of a new book.
* In this part, all the information of a book including
numPages, numAuthor, authorList,
* name, next will be initialized.
* Note that next would be initialized as nullptr in the
constructor, and its value would
* be set in main.cpp after a book is constructed.
* Remember to allocate memory for variable name, numAuthor, and
each element in the array
* numAuthor.
*/
Book::Book(const char * name, char * const * authorList, int
numPages, int numAuthor) {
}
/*
* Task 2: Destructor to delete an existing book.
* In this part, all the memory allocated previously in the
constructor should be deallocated.
* Note that for an array (e.g., numAuthor), the array as a whole
and each element in the
* array should be deallocated respectively.
*/
Book::~Book() {
cout << "Delete the book titled
\"" << name << "\"" << endl;
}
--------------------------------
Book.h is provided underneath:
#ifndef BOOK_H_
#define BOOK_H_
class Book
{
private:
// Stores a list of author names of a book.
char **authorList;
// Stores the title of the book.
char *name;
// Stores the number of pages and authors of a book.
int numPages, numAuthor;
// Stores the pointer of the next book within the whole library management system (the
// linked list).
Book *next;
public:
// Task 1: Constructor of a new book.
Book(const char *name, char * const * authorList, int numPages = 0, int numAuthor = 0);
// Task 2: Destructor to delete an existing book.
~Book();
// Task 3: Search for and print out information of book(s) with a given name.
void printBookInfoByName(const char * name) const;
// Task 4: Search for and print out information of book(s) of a given author.
void printBooksInfoByAuthor(const char * authorName) const;
// A given function to print out the information of all the books.
void printAllBooks() const;
// A given function to print out the information of one single book.
void printSingleBookInfo() const;
// Set the value of next to a given pointer.
void setNext(Book* book);
// Task 5: Search for and delete book(s) of a given name.
void deleteBookByName(const char * name);
// Get the name of one single book.
const char* getName() const;
// Get next of a book.
Book* getNext();
};
#endif /* BOOK_H_ */
Introduction In this lab, we will use class to design a library management system. In the library management system, we defined a class called Book to store all the information of a book, including name, number of pages, number of authors and author names. Also, since the books are stored by a linked list, there would a pointer next pointing to the next book. To simplify, we use a string without space to store the names of books and authors. For example, if a name is "Abc Def Ghi", we use "Abc_Def_Ghi" to represent it.

Tasks There are 5 tasks in book.cpp. Descriptions of tasks are provided below, instructions and some examples are also provided via comments in the skeleton codes. • Task 1: Constructor of a new book. In this part, all the information of a book including numPages, numAuthor, authorList, name, next will be initialized. Note that next would be initialized as nullptr in the constructor, and its value would be set in main.cpp after a book is constructed. Alao, remember to allocate memory for variable name, numAuthor, and each element in the array numAuthor. • Task 2: Destructor to delete an existing book. In this part, all the memory allocated previously in the constructor should be deallocated. Note that for an array (e.g., numAuthor), the array as a whole and each element in the array should be deallocated respectively.
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply