Create a bookfactory to construct the required object

Assignment Help Computer Engineering
Reference no: EM132158177

ONLY USE:

#include <iostream>

#include <fstream>

#include <iomanip>

using namespace std;

Write a C++ program that inputs from a file and outputs data to the screen. A base class called book defines the name, type and number of pages in a book. An integer called code is set to 0 for Fiction, 1 for Nonfiction, 2 for Reference. Fiction, Nonfiction and Reference derive from book. Fiction contains a field describing the genre of the Fiction. Nonfiction has two fields: subject and number of illustrations. The data file (books.txt) contains

0 Thunderball 245 Spy

0 Larceny 289 Mystery

1 Airplanes 456 Aviation 250

0 Killer 198 Drama

1 Football 434 Sports 400

1 Lincoln 432 History 307

2 Dictionary 987

2 Atlas 414

producing this output:

Name:Thunderball Type:Fiction Pages:245 Genre:Spy

Name:Larceny Type:Fiction Pages:289 Genre:Mystery

Name:Airplanes Type:Nonfiction Pages:456 Subject:Aviation Illustrations:250

Name:Killer Type:Fiction Pages:198 Genre:Drama

Name:Football Type:Nonfiction Pages:434 Subject:Sports Illustrations:400

Name:Lincoln Type:Nonfiction Pages:432 Subject:History Illustrations:307

Name:Dictionary Type:Reference Pages:987

Name:Atlas Type:Reference Pages:414

Total pages:3455

In main, a single class variable of Book called book is used to store each book of either fiction, nonfiction or reference. Make an enum type for books called Books.

Create a BookFactory to construct the required objectand use the enum Books. Use virtual functions to read and print the data.

Each class can read only the data declared in it. Each class can print only the data declared in it. A count of the total number of pages of all books in the data is maintained by class book.

Create a PrintAll function for printing books. PrintAll's prototype is

void PrintAll(Book* book);

PrintAll calls the polymorphic Print method of book (the parameter in PrintAll). Remember that each class is responsible for reading and printing its own data. So Fiction, Nonfiction and Reference shouldn't print name, type and the number of pages from Book.

This assignment is about polymorphism, virtual methods, and proper assignment of class responsibility. Each class must read and print its data.

MUST FOLLOW THESE INSTRUCTIONS EXACTLY

Reference no: EM132158177

Questions Cloud

Write a search method to determine if a word is in the list : Write a search method to determine if a word is in the list or not and a separate insert method. You will need a print method as well.
Write a method called remove that accepts one arraylist : Write a method called remove that accepts one ArrayList parameter and one char parameter.
Write a menu driven script that calls a trash script : Using the select command from the korn shell, write a menu driven script that calls a trash script in the given manner.
Identify and discuss one disadvantage or possible downside : What are the benefits? Identify and discuss one disadvantage or possible downside.
Create a bookfactory to construct the required object : Create a BookFactory to construct the required object and use the enum Books. Use virtual functions to read and print the data.
Discuss how the development of a mental health policy : Discuss how the development of a mental health policy might decrease the stigma attached to mental health disorders.
Write a python program that prompts for an integer : Write a Python Program that prompts for an integer and prints the integer, but if something other than an integer is input, the program keeps asking.
Prompt the user to enter a linear equation of the form : The program should prompt the user to enter a linear equation of the form aY + b = c where a, b, and c are real numbers of type double.
Have all invested in global seed banks : Very different organisations, such as governments, industry, and environmental agencies, have all invested in global seed banks.

Reviews

Write a Review

Computer Engineering Questions & Answers

  Create a well-formatted time plot of the data using r

Create a well-formatted time plot of the data using R. Create a line graph of the series at a yearly aggregated level (i.e., the total shipments in each year).

  Computer platformscomputer systems may be classified into

computer platformscomputer systems may be classified into two categories classical and quantum. this assignment will

  Compare static and dynamic linking

Compare static and dynamic linking. What are the shortcomings of 3GLs in meeting the requirements of modern applications?

  How you kept it secure while you waited for her

How you kept it secure while you waited for her, and the transfer of responsibility for the computer from you to her. What kind of document is it?

  You are senior forensics investigator in a corporate firm

you are senior forensics investigator in a corporate firm that handles large financial transactions for a for a variety

  Draw the decision tree

A café in Newport has two purchasing decisions; buy high quality bread or lower quality bread for its customers. They can purchase the high quality bread.

  How many frames per second do a T-one and SONET transmit

How many frames per second do a T-1 and SONET transmit? Why this number?

  Design a sequential circuit whose state diagram is given

Design a sequential circuit whose state diagram is given in Fig. using a 3-bit register and a 16 x 4 ROM.

  Outline the issues that susan should consider

Outline the issues that Susan should consider which would support the development of a custom software application in-house. Outline the issues that Susan should consider which would support the purchase of a software package.

  What is a task pane

What are the different kinds of Window controls? What is the purpose of each.

  Explain different types of congestion in network layer

Explain different types of congestion in network layer?

  Develop proposed improvements to theory and practice

Develop proposed improvements to theory and practice in software management. Apply project management techniques to manage resources and issues in software.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd