Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Ive included that program codes and it is marked where they need codes to be fil

ID: 3543400 • Letter: I

Question

Ive included that program codes and it is marked where they need codes to be filled in. Can you please help out? The places that need to be filled in have comments with descirptions of what to put in.

//File: storeClassd.h
//
//This is the specification file for a store class.
//Each store contains data members that contain
//information about chairs and tables sold by the store
//as well as the name of the store.

#include <string>
using namespace std;

//prevent multiple inclusions
#ifndef STORE_CLASS_H
#define STORE_CLASS_H

class StoreClass
{
public:
    //Read the data for a store from a file.  The name of the
    //file is passed as an argument to this method
    void readFile (string filename);

    //print information about the store
    void printStore();

    //add the overloaded == operator here

private:
    //define a struct for a Chair type
    struct Chair
    {
        string designer;   //chair designer's name
        bool cushion;      //does it have a cushion
        string material;   //type of material used in the chair
        string color;      //color of the chair
        int qty;           //quantity of this chair
    };

    //define a struct for a Table type
    struct Table
    {
        string designer;   //table designer's name
        bool glass;        //does the chair have glass
        string material;   //type of material used in the table
        string color;      //table's color
        int qty;           //quantity of this table
    };

    //data members in the store
    Chair chairArray[100];  //the store contains many chairs
    Table tableArray[100];  //and many tables
    int totalTables;        //number of tables
    int totalChairs;        //number of chairs
    string storeName;       //name of the store

};

#endif


******************************

Explanation / Answer

//File: storeClassd.h
//
//This is the specification file for a store class.
//Each store contains data members that contain
//information about chairs and tables sold by the store
//as well as the name of the store.

#include <string>
using namespace std;

//prevent multiple inclusions
#ifndef STORE_CLASS_H
#define STORE_CLASS_H

class StoreClass
{
public:
//Read the data for a store from a file. The name of the
//file is passed as an argument to this method
void readFile (string filename);

//print information about the store
void printStore();

//add the overloaded == operator here
bool operator==(StoreClass &S1);
private:
//define a struct for a Chair type
struct Chair
{
string designer; //chair designer's name
bool cushion; //does it have a cushion
string material; //type of material used in the chair
string color; //color of the chair
int qty; //quantity of this chair
};

//define a struct for a Table type
struct Table
{
string designer; //table designer's name
bool glass; //does the chair have glass
string material; //type of material used in the table
string color; //table's color
int qty; //quantity of this table
};

//data members in the store
Chair chairArray[100]; //the store contains many chairs
Table tableArray[100]; //and many tables
int totalTables; //number of tables
int totalChairs; //number of chairs
string storeName; //name of the store

};

#endif



//File: storeClassd.cc
//
//This is the implementation file for a store class.
//Each store contains data members that contain
//information about chairs and tables sold by the store
//as well as the name of the store.

#include "storeClassd.h"
#include <iostream>
#include <fstream>
#include <string>
#include <cstdlib>
using namespace std;

//This method receives the name of the file containig
//store data. It reads all data about the store.
//The data file contains the name of the store followed
//by information about chairs and tables. If a chair's
//information appears in the file, it is preceeded by
//the string "Chair". If a table's information appears
//in the file, it is preceeded by the string "Table".
void StoreClass::readFile(string filename)
{
string input; //input a string from the file
ifstream myFile; //input file stream
totalChairs = 0; //set the chair counter to 0
totalTables = 0; //set the table counter to 0

//open the data file & check to make sure it opened
myFile.open(filename.c_str());
if (!myFile)
{
cerr << "Data file failed to open! ";
exit (0);
}

//read the store's name
myFile >> input;

//check for an empty file
if(input!="")
{
//set the store's name
storeName = input;

//read in chairs & tables until end-of-file
//read the type of the next item
myFile >> input;
while(myFile)
{


//the next item is a chair
if(input == "Chair")
{
//create a Chair object and fill it with data
Chair chair1;
myFile >> chair1.designer;
myFile >> chair1.color;
myFile >> chair1.material;

//read a string to indicate whether the chair
//has a cushion or not
myFile >> input;
if(input == "true")
{
chair1.cushion = true;
}
else
chair1.cushion = false;
myFile >> chair1.qty;

//place the chair into the array of chairs
chairArray[totalChairs] = chair1;
totalChairs +=1;
}
//the next item is a table
else if(input == "Table")
{
//create a Table object and fill it with data
Table table1;
myFile >> table1.designer;
myFile >> table1.color;
myFile >> table1.material;

//read a string to indicate whether the table
//has glass or not
myFile >> input;
if(input == "true")
{
table1.glass = true;
}
else
table1.glass = false;
myFile >> table1.qty;

//place the chair into the array of tables
tableArray[totalTables] = table1;
totalTables+=1;
}
//read the type of the next item
myFile >> input;

}
}
}

//This method prints all information about all tables
//and chairs in the store.
void StoreClass::printStore()
{
//print all information about Chairs sold by
//the store
if (totalChairs > 0)
cout << "Inventory of Chairs" << endl;
else
cout << "No chairs in Inventory" << endl;
for(int i = 0; i < totalChairs; i++)
{
cout << chairArray[i].designer <<" ";
cout << chairArray[i].color << " ";
cout << chairArray[i].material << " ";
if(chairArray[i].cushion == true)
cout << "Cushioned " <<endl;
else
cout << "Not Cushioned " << endl;
cout << "Qty in Stock: " << chairArray[i].qty << endl;
}

//print all information about Tables sold by
//the store
if (totalTables > 0)
cout << " Inventory of Tables" << endl;
else
cout << " No tables in Inventory" << endl;
for(int i = 0; i < totalTables; i++)
{
cout << tableArray[i].designer <<" ";
cout << tableArray[i].color << " ";
cout << tableArray[i].material << " ";
if(tableArray[i].glass == true)
cout << "Glass Top " <<endl;
else
cout << "No Glass Top " << endl;
cout << "Qty in Stock: " << tableArray[i].qty << endl;
}

}

// Create the == operator for the store class. The overloaded
// operator should compare only the store names to determine
// equality. You must include all appropriate code. Be sure
// to check only the name of the store to determine equality.
bool StoreClass::operator==(StoreClass &S1)
{
return (storeName.compare(S1.storeName)==0);
}

//File: inlab7d.cc
//
//This is a simple test program to test the
//store class.

#include <string>
#include "storeClassd.h"
#include <iostream>

using namespace std;

int main()
{
//Three file names for reading store data
string file1 = "ex12_data.0";
string file2 = "ex12_data.1";
string file3 = "ex12_data.2";

//create three different stores
StoreClass store1;
StoreClass store2;
StoreClass store3;

//read the data for each store
store1.readFile(file1);
store2.readFile(file2);
store3.readFile(file3);

//check to see if the stores 1 and 2 have the same name
if( store1 == store2)
cout << "The stores are the same." << endl;
else
cout << "The stores are different" << endl;

//check to see if the stores 2 and 3 have the same name
if( store2 == store3)
cout << "The stores are the same." << endl;
else
cout << "The stores are different" << endl;
system("pause");
return 0;
}