You are to write a
program that uses classes to read in information of books, print them (in
unsorted order), sort them and print them (in sorted order) again.
There are two classes
you will implement: CBook, and CLibrary.
There header files are provided below.
CBook.h
#pragma once
#include <string>
class CBook
{
private:
std::string mTitle;
std::string mAuthor;
int mYearPublished;
public:
CBook();
CBook(std::string Title, std::string Author, int YearPublished);
~CBook();
std::string GetTitle() const;
std::string GetAuthor() const;
int GetYearPublished() const;
void SetBook(std::string Title, std::string Author, int YearPublished);
void SetTitle(std::string Title);
void SetAuthor(std::string Author);
void SetYearPublished(int YearPublished);
void Swap(CBook &Book);
};
CLibrary.h
#pragma once
#include "CBook.h"
class CLibrary
{
private:
int mNumBooks;
CBook *mBooks;
std::string mInputFileName;
std::string mOutputFileName;
public:
CLibrary();
CLibrary(std::string InputFileName, std::string OutputFileName);
~CLibrary();
private:
void Sort(CBook *Books, int Size);
public:
void ReadBooks();
void Sort();
void PrintBooks(std::string Header);
};
Input spec:
First line: Number of books
Second line down: Repetition of the following (Number of
books) times:
Title, (in a line by itself)
Author, (in a line by itself)
Year
Published (in a line by itself)
• In
the destructor, you need to perform a thorough cleanup. If there are dynamically allocated arrays or
memories that have not been deleted, you need to delete them. If there are files still opened, you need to
close them. This will be checked
strictly.
• If
you need to add member variables and/or member functions, make them private.
• Each
book will be printed in one line. The
first character of Title should be lined up, and the same for the Author.
• In
the first three lines of the output, print your name, section, and assignment
number.
The official input
will be available by 5/26/2020.
In every program file
(.cpp and/or .h) you turn in, use comment lines to show the following:
//Your name
//Section
//Assignment number
Submissions with no
name, section, and assignment number will be asked to resubmit.
Turn in the following
for credit.
all .cpp files
output file
Get Free Quote!
401 Experts Online