100% Guaranteed Results


CS201 – Homework
$ 20.99
Category:

Description

5/5 – (1 vote)

In this homework, you will implement a book collection system. A book collection has a list of genres (e.g., science fiction). Each genre is denoted with a unique name and a list of books under that genre. Each book is identified by a unique name and a list of authors. In your implementation, you MUST use linked lists. This homework will have two parts, whose requirements are explained below.
PART A:
To take the final exam, you MUST submit at least this part and MUST get at least half of its points.
This part is a simplified version of the entire system, where the user just creates the book collection and enters the genres only. So the system does not contain any books (so no authors either). In this system, you must keep the genres in a linked list of the Genre objects. Thus, you must implement the Genre class first. This class is quite simple for Part A, but you will have to extend it for Part B.
1. Below is the required part of the Genre class. The name of the class must be Genre. The interface for the class must be written in a file called SimpleGenre.h and its implementation must be written in a file called SimpleGenre.cpp.
▪ The Genre class keeps the name of the genre as the only data member. Make sure to implement the get function for this data member since we will use them to test your program.
2. Do not delete or modify any part of the given data members or member functions. You are not allowed to define additional functions and data members to this class for Part A.
#ifndef __SIMPLE_GENRE_H
#define __SIMPLE_GENRE_H

#include <string> using namespace std;

class Genre { public:
Genre(const string gname = “”);
~Genre ();
Genre (const Genre &genreToCopy); void operator=(const Genre &right); string getGenreName() const;
void setGenreName(const string gName);
private:
string genreName;
};
#endif

3. Below is the required part of the BookCollection class that you must write in Part A of this assignment. The name of the class must be BookCollection. The interface for the class must be written in a file called SimpleBookCollection.h and its implementation must be written in a file called SimpleBookCollection.cpp. Do not delete or modify any part of the given data members or member functions. You are not allowed to define additional functions and data members to this class for Part A.
#ifndef __SIMPLE_BOOKCOLLECTION_H
#define __SIMPLE_BOOKCOLLECTION_H
#include <string> using namespace std;
#include “SimpleGenre.h”

class BookCollection{ public:
BookCollection();
~BookCollection();
BookCollection(const BookCollection& bcToCopy); void operator=(const BookCollection& right); void displayGenres() const; bool addGenre(const string genreName); bool removeGenre(const string genreName); string getName() const; void setName(const string bcName);
private:
struct GenreNode { Genre g;
GenreNode* next;
};

string name; int genreCount;
GenreNode* head;
GenreNode* findGenre(string genreName);

};
#endif

Things to do:
▪ Implement the default constructor, which creates an empty book collection system. Also overload the assignment operator and implement the destructor and copy constructors.
▪ Implement the getter/setter functions for the name data member.
▪ Implement the add and remove genre functions whose details are given below:
Otherwise, if the genre does not exist in the system, add the genre to the system and return true. Note that names are case insensitive (i.e., Fantasy and FANTASY are the same thing).
Display all genres: This function should display the names of all genres in the system one per line. If the there are no genres in the system, display –EMPTY–.

Genre name1
Genre name2 · · ·

What to submit for Part A?
You should put your SimpleGenre.h, SimpleGenre.cpp, SimpleBookCollection.h and SimpleBookCollection.cpp files into a folder and zip the folder. In this zip file, there should not be any file containing the main function. The name of this zip file should be: PartA_secX_Firstname_Lastname_StudentID.zip where X is your section number. Then follow the steps that will be explained at the end of this document for the submission of Part A.
What to be careful about implementation and submission for Part A?
You have to read “notes about implementation” and “notes about submission” parts that will be given at the end of this document.
PART B:

#ifndef __AUTHOR_H
#define __AUTHOR_H #include <string> using namespace std;

class Author{ public:
Author();
Author(const int id, const string name); int getID() const; void setID(const int id); string getName() const; void setName(const string id); private:
string name; int id;
};
#endif

#ifndef __BOOK_H
#define __BOOK_H

#include <string> using namespace std;
#include “Author.h”

class Book{ public:
Book();
Book(const string name);
~ Book();
Book(const Book& bookToCopy); void operator=(const Book& right); string getName() const; void setName(const string bookName); bool addAuthor(const int id, const string name); bool removeAuthor (const int id); void displayAuthors() const;
private:
struct AuthorNode { Author a;
AuthorNode* next;
};
AuthorNode* head; string name;

AuthorNode* findAuthor(int id);
};
#endif

Here is some information about the functions to be implemented in the Book class:

Display authors: This function lists all authors added to the book. The output should be in the following format. If the there are no authors of the book, display –EMPTY–.

Author ID1, Author name1
Author ID2, Author name2
· · ·

After extending the Genre class, now work on the implementation of the following functionalities that your BookCollection system should support:

1. Add a genre
2. Remove a genre
3. Display all genre
4. Add a book to a genre
5. Remove a book from a genre
6. Add an author to a book in a genre
7. Remove an author from a book in a genre
8. Show detailed information about a particular genre
9. Find the genre (s) and book(s) associated with a specific author id

Display all genres: This function lists all genres already registered in the system. The output should be in the following format. If the there are no genres in the system, display –EMPTY–.

Genre name1
Genre name2
· · ·

Add a book to the genre: This function adds a book to the book list of a genre. The genre name for which the book is submitted to and the name of the book are specified as parameters. Note that the author list is initially empty and authors will be added later. In this function, you should take care of the following issues:

Add an author to a book in a genre: This function adds an author to a book in a given genre. The genre name for which the book will be entered to, and the name of the book are specified as parameters along with the author name and author id. In this function, you should take care of the following issues:

Show detailed information about a particular genre: This function displays all of the information about a genre whose name is specified as a parameter. The output should be in the following format. If the genre with the specified name does not exist in the system, display –EMPTY– after the first line. Authors of a book will be listed following the book name and will start after a tab.

Genre name
Book name1
Author ID1, Author name1
Author ID2, Author name2
Book name2
Author ID3, Author name3
Author ID4, Author name4
Author ID5, Author name5

Find the genre(s) and book(s) associated with a specific author: This function lists all the genres whose book lists contain the specified a book which is authored by the given author ID. Multiple genres can have multiple books, which can have the same author id. The output should be in the following format. If the specified author does not participate in any book, display –EMPTY– after the author ID and name. Found book names follow the genre name and start after a tab.

Author ID, Author name
Genre name (for the 1st genre)
Book name (for the 1st book in 1st genre)
Book name (for the 2nd book in 1st genre)
Genre name (for the 2nd genre)
Book name (for the 1st book in 2nd genre)
Book name (for the 2nd book in 2nd genre)
Book name (for the 3rd book in 2nd genre)
· · ·

#ifndef __BOOKCOLLECTION_H
#define __BOOKCOLLECTION_H
#include <string> using namespace std; #include “Genre.h” class BookCollection { public:
BookCollection();
~BookCollection();
BookCollection(const BookCollection& bcToCopy); void operator=(const BookCollection& right); void addGenre(string genreName); void removeGenre (string genreName); void displayAllGenres() const;
void addBook(string genreName, string bookName); void removeBook(string genreName, string bookName);
void addAuthor(string genreName, string bookName, int authorID, string authorName);
void removeAuthor(string genreName, string bookName, int authorID); void displayGenre(string genreName); void displayAuthor(int authorID); private:
struct GenreNode {
Genre g;
GenreNode* next;
};
GenreNode *head; int genreCount;
GenreNode* findGenre(string genreName);
};
#endif
What to submit for Part B?

You should put your Book.h, Book.cpp, Author.h, Author.cpp. Genre.h, Genre.cpp, BookCollection.h, and BookCollection.cpp (and additional .h and .cpp files if you implement additional classes) into a folder and zip the folder. In this zip file, there should not be any file containing the main function. The name of this zip file should be: PartB_secX_Firstname_Lastname_StudentID.zip where X is your section number. Then follow the steps that will be explained at the end of this document for the submission of Part B.

What to be careful about implementation and submission for Part B?

You have to read “notes about implementation” and “notes about submission” parts that will be given just below.

NOTES ABOUT IMPLEMENTATION (for both Part A and Part B):

1. You MUST use LINKED-LISTs in your implementation. You will get no points if you use automatically allocated arrays, dynamic arrays or any other data structures such as vector/array from the standard library.
3. You ARE NOT ALLOWED to use any global variables or any global functions.
4. Your code must not have any memory leaks for Part A and Part B. You will lose points if you have memory leaks in your program even though the outputs of the operations are correct.
5. Your implementation should consider all names as case insensitive.

NOTES ABOUT SUBMISSION (for both Part A and Part B):

4. No hard copy submission is needed. The standard rules about late homework submissions apply.
5. Do not submit any files containing the main function. We will write our own main function to test your implementations.
“dijkstra.ug.bcc.bilkent.edu.tr” before submitting your assignment.

Reviews

There are no reviews yet.

Be the first to review “CS201 – Homework”

Your email address will not be published. Required fields are marked *

Related products