(Solved) : Simple C Std Functions Please Code Main Implement Simple Database Store Sells Printed Fil Q42769122 . . .

simple c++ and no std:: functions please. the code forthe main is below.

Implement a simple database for a store that sells printed andfilm media items including films, books, magazines and newspapers.For a Magazine, the bar-code, issn number,publisher name, volume and number of data items are stored. For aBook, the bar code, the title, the author, thepublisher and the book’s isbn number are stored. For aNewspaper, the bar-code, the newspaper name, thecity and daily distribution volume are stored. For afilm, the barcode, the film title, leading actorname and production year data items are stored.

The media store classes, as shown above, can be arranged as theinheritance hierarchy presented above.Media is anabstract class; whereas,Printed and the rest of the classes areconcrete ones. ThePrinted class has number of pages (nump)and date of print as data members. A minimal description for theMedia class is as follows (you are allowed to redefine this classor add to it any data member and/or member functions as you seefit):

class Media {


Media (char* p = NULL,char  = ‘A’, int = 1);

Media (const Media &);

Media & Operator= (const Media&);

~Media ( );

int getBarCode ();     // returns the bar-code of themedia item

virtual void print ( ) = 0;


char*title;                   //pointer to a dynamically allocated array that store title

int barCode;

char    status;                //‘A’: available in stock, ‘S’: sold.

MediaTypemt;    // enum- 0: Magazine, 1: Book, 2:Newspaper, 3:Film.


When the Media store is closed, the data describing the store’sstock are stored in the file stock.txt. The firstline in that file stores the number of media items in Stock. Thefirst line is followed by a number of lines; each line stores thedata items, separated by commas, describing a single media item (aparticular video or book) as well as the type of the describeditem.

When the store is open, the media items (stock) are modeled asobjects of Magazine, Book, Newspaper or Film classes. The Storekeeps track of the media objects using a StockTab object. A minimaldefinition for StockTab class is presented below (again you areallowed to redefine this class or add to it any data member and/ormember functions as you see fit), namely:

class StockTab {


StockTab(  );     // DefaultConstructor.


intitemCount;   //number of stock items currentlyavailable

Media**mptr;      // table of pointers tomedia objects. The last entry is NULL


The store keeps track of the transactions that take place duringthe normal business hours. These transactions can be of differenttypes such as sale transaction,return-an-item transaction,..etc. A transaction ismodeled as a class with the following minimal definition (again youare allowed to redefine this class or add to it any data memberand/or member functions as you see fit).

class Transaction {


Transaction (int , char,  char , float, Media *);  


int trans_id;

chartype;      // ‘S’: sale, ‘R’: return.‘P’: replace..etc.

char payment; // method of payment.‘C’: credit card. ‘S’: cash

float amount;   //

Media *mptr;    // pointer to the media item involvedin the transaction


The Media store keeps also track of sale transactions using aSaleTranxs object. SaleTranxs class is defined as follows,namely:

class SaleTranxs {


SaleTranx ( );

SaleTranx &operator+= (constMedia* );   // Add a new transaction


Transaction  **ptrans   //



* Read the data items from thestock.txt file and create the corresponding mediaobjects. To keep track of these objects, create a StockTabobject and store within this object the pointers to themedia objects.

* Create anempty  saleTranxs object

Code for themain:

void main ( ) {

// read stock.txt file into memory andcreate the corresponding Media

// objects.

// create a StockTab object andpopulate it with pointers to media objects.

While (1) {

cout << “Please select form thefollowing menu: “ << endl;

cout << endl;

cout << “1. Buy a mediaitem “ << endl;// change the item status in StockTabobject to sold (S) and insert a sale transaction into SaleTranxstable

cout << “2. Return a media item” <<endl;// Change the item status in StockTab object to available (A)and insert a transaction into SaleTranxs table.

cout << “3. Replace a media item“ << endl;// Insert a return transaction intoSaleTranxs table and Change the item status in StockTab object toavailable (A). Change the status of the new item in StockTab toavailable (A) and insert a sale transaction for this item intoSaleTranxs.

cout <<“4. Generate AvailableStock Report “ <<endl;// Print out all the unsolditems in stock ( StockTab).

cout <<“5. Generate Sold StockReport “ <<endl;// Print out all the items currentlyin SaleTranxs table.

cout << “ 6. Generate Transaction Report”<< endl;// Store the non-sold media objectsof  StockTab and their count into stock.txt file and thenexit the program

cout << “7.Close” << endl;//Store the non-soldmedia objects of  StockTab and their count intostock.txt file and then exit the program

cout << “Pease enter your choice> “;

cin >> choice;

switch (choice){

   case 1: call thefunction that handles buying an item;


   case 2: call thefunction that handles returning an item;



   case 7: store stockitem in stock.txt;

          exitthe program;


you should also add the values in thestock.txt

stocks.txt file(can be changed):2Harry Potter, 1234, A, 3Hamlet, 6789, S, 1

Expert Answer

Answer to simple c++ and no std:: functions please. the code for the main is below. Implement a simple database for a store that s…

Leave a Comment


We are the best freelance writing portal. Looking for online writing, editing or proofreading jobs? We have plenty of writing assignments to handle.

Quick Links

Browse Solutions

Place Order

About Us