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

  Explain what is a virtual machine

What is a virtual machine? Discuss this definition in terms of the Pep/7 computer. Describe the features of the Pep/7 CPU that we covered in this chapter.

  Which names in php are case sensitive and which are not

Which names in PHP are case sensitive and which are not? How can a variable be tested to determine whether it is bound?

  Develop a checkout lane simulation

Develop a checkout lane simulation that can be used to determine the optimal number of lanes that Cougar Mart should have open.

  You will write an extensive research paper on an

you will write an extensive research paper on an entrepreneurship failure. as you may be aware 80 of all small

  Display comments and identified source codes

Write and manually assemble the following programs. All memory addresses include the starting and ending addreses. display comments and identified source codes.

  Distinguish between multiprocessors and multi-computers

Distinguish between multiprocessors and multi-computers based on their structures. resource sharing. and inter-processor communications.

  Create a modular program to prepare a customers bill

During the tax season, every Friday, the J&J accounting firm provides assistance to people who prepare their own tax returns.

  Explain how advances in technology affect digital forensics

Analyze the impact of technological changes on digital forensics techniques. Explain how advances in technology affect digital forensics. Examine changing methods for extracting evidence from a new technology.

  Process a purchase transaction

Process a purchase transaction via PX Batch Upload, with your full name in the merchant reference field, and refund this transaction via PX batch upload.

  Create a two-dimensionsl array depending on user choices

design an application that either sums or averages the rows or columns of a two-dimensionsl array depending on user choices. Use following data for the array.

  What are the challenges in rolling out a business

What is "enterprise-wide analytics technology," and how can it play a part in understand business processes? What are the challenges in rolling out a Business Intelligence tool.

  Identify the critical requirements of the audit

Identify the critical requirements of the audit for your chosen organization and explain why you consider them to be critical requirements.

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