Question
Milestone 4The Book class This milestone will require the following modules and header files: Lib.h Uitls Date Streamable Publication The Book class implementation The Book
Milestone 4The Book class
This milestone will require the following modules and header files:
- Lib.h
- Uitls
- Date
- Streamable
- Publication
The Book class implementation
The Book class is derived from the Publication class. A book is a publication with an "Author name".
The book class only has one attribute that is a pointer to a character to hold an author's name Dynamically.
Construction
A book is created empty by default, in a safe empty state.
The rule of three
Implement what is needed to comply with the rule of three so a book can safely be copied or assigned to another book.
Methods
The book class overrides the following virtual methods and type conversion operator.
- type
- write
- read
- set
- operator bool()
Method implementations:type method
Returns the character "B".
write method
- First, it will invoke the write of its Base class.
- If the incoming argument is a console IO object.
- writes a single space
- writes the author's name in SDDS_AUTHOR_WIDTH spaces. If the author's name is longer than the SDDS_AUTHOR_WIDTH value, it will cut it short and writes exactly SDDS_AUTHOR_WIDTH characters. Note that this should not modify the author's name.
- writes " |"
- If the incoming argument is not a console IO object
- writes a tab character '\t'
- writes the author's name
- returns the incoming ostream.
Read
Read the author name in local variables before setting the attribute to any value. (to make it easier lets assume the author's name can not be more than 256 characters)
- First, invoke the read of the Base class.
- Free the memory held for the author's name
- If the incoming argument is a console IO object
- ignore one character (skip the ' ')
- prompt "Author: "
- read the author's name
- If the incoming argument is not a console IO object
- ignore the tab character
- read the author's name
Then if the incoming istream object is not in a fail state, dynamically hold the author's name in the char pointer attribute of the book class.
At the end return the incoming istream object.
set
- invoke the set of the base class to set the member id
- reset the date to the current date.
operator bool()
return true if the author's name exists and is not empty and the base class's operator bool() has returned true.
the Tester program
// Final Project Milestone 4 // Book // File ms4_tester.cpp // Version 1.0 // Author Fardad Soleimanloo // Revision History // ----------------------------------------------------------- // Name Date Reason // This will not change the output ///////////////////////////////////////////////////////////////// #include
MS4 tester program output
MS4 tester output
MS4 Submission
If you would like to successfully complete the project and be on time, start early and try to meet all the due dates of the milestones.
Upload your source code and the tester program (Utils.cpp, Utils.h, Date.cpp, Date.h, Streamable.cpp, Streamable.h, Publication.cpp, Publication.h,Book.cpp,Book.h,Books.txt, and ms4_tester.cpp) to your matrix account. Compile and run your code using the g++ compiler as shown in the introduction and make sure that everything works properly.
Then, run the following command from your account (replace profname.proflastname with your professor's Seneca userid):
~profname.proflastname/submit 2??/prj/m?
the link of the question :
https://github.com/Seneca-244200/OOP-Project#milestone-4
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started