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

  Mathematics in computing

Binary search tree, and postorder and preorder traversal Determine the shortest path in Graph

  Ict governance

ICT is defined as the term of Information and communication technologies, it is diverse set of technical tools and resources used by the government agencies to communicate and produce, circulate, store, and manage all information.

  Implementation of memory management

Assignment covers the following eight topics and explore the implementation of memory management, processes and threads.

  Realize business and organizational data storage

Realize business and organizational data storage and fast access times are much more important than they have ever been. Compare and contrast magnetic tapes, magnetic disks, optical discs

  What is the protocol overhead

What are the advantages of using a compiled language over an interpreted one? Under what circumstances would you select to use an interpreted language?

  Implementation of memory management

Paper describes about memory management. How memory is used in executing programs and its critical support for applications.

  Define open and closed loop control systems

Define open and closed loop cotrol systems.Explain difference between time varying and time invariant control system wth suitable example.

  Prepare a proposal to deploy windows server

Prepare a proposal to deploy Windows Server onto an existing network based on the provided scenario.

  Security policy document project

Analyze security requirements and develop a security policy

  Write a procedure that produces independent stack objects

Write a procedure (make-stack) that produces independent stack objects, using a message-passing style, e.g.

  Define a suitable functional unit

Define a suitable functional unit for a comparative study between two different types of paint.

  Calculate yield to maturity and bond prices

Calculate yield to maturity (YTM) and bond prices

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