Question: The header and implementation files for the Artifact class are given below. An Artifact object has a name, origin, and era data members all of

The header and implementation files for the Artifact class are given below. An Artifact object has a name, origin, and era data members all of which are strings. The class also defines constructors, setters, getters, and a toString function.

Artifact.h

#ifndef ARTIFACT_H

#define ARTIFACT_H

#include

class Artifact{

public:

Artifact(std::string, std::string, std::string);

Artifact();

~Artifact();

void setName(std::string);

std::string getName()const;

void setOrigin(std::string);

std::string getOrigin()const;

void setEra(std::string);

std::string getEra()const;

std::string toString()const;

private:

std::string name;

std::string origin;

std::string era;

};

#endif

Artifact.cpp

#include "Artifact.h"

#include

#include

Artifact::Artifact(std::string name, std::string origin, std::string era)

{

this->name = name;

this->origin = origin;

this->era = era;

}

Artifact::Artifact(){}

Artifact::~Artifact(){}

void Artifact::setName(std::string name){ this->name = name;}

std::string Artifact::getName()const{ return name;}

void Artifact::setOrigin(std::string origin){ this->origin = origin;}

std::string Artifact::getOrigin()const{ return origin;}

void Artifact::setEra(std::string era){ this->era = era;}

std::string Artifact::getEra()const{ return era;}

std::string Artifact::toString()const{

std::ostringstream output;

output << " Artifact name: " << getName() << " Origin: " << getOrigin() << " Era: " << getEra();

return output.str();

}

Event.h

#ifndef EVENT_H #define EVENT_H #include

class Event{ public: Event(std::string, std::string, std::string); ~Event(); void setStartDate(std::string); std::string getStartDate()const; void setEndDate(std::string); std::string getEndDate()const; void setLocation(std::string); std::string getLocation()const; std::string toString()const;

private: std::string startDate; std::string endDate; std::string location; }; #endif

Event.cpp

#include "Event.h" #include #include #include

Event::Event(std::string sDate, std::string eDate, std::string loc) { startDate = sDate; endDate = eDate; location = loc; }

Event::~Event(){ }

void Event::setStartDate(std::string sDate){ startDate = sDate; } std::string Event::getStartDate()const { return startDate; } void Event::setEndDate(std::string eDate) { endDate = eDate; } std::string Event::getEndDate()const { return endDate; } void Event::setLocation(std::string loc){ location = loc; } std::string Event::getLocation()const { return location; } std::string Event::toString()const{ std::ostringstream output; output << " Start date: " << getStartDate() << " End Date: " << getEndDate() << " Location: " << getLocation(); return output.str(); }

Step 1. Define Exhibit.h (40 points)

  • Start with adding include guards for your class.
  • Then include the necessary libraries and header files. At this point, Exhibit class needs Event and Artifact class headers and string library.
  • Exhibit class inherits from Event class. Establish the inheritance relationship.
  • Exhibit class has three private data members.
  • title is of type string, represents the title of the exhibit
  • artList is of type Artifact *, represents a pointer to an array of Artifact objects
  • numArtifacts is of type int, represents the number of artifacts in the artList array.

  • Define the constructor and the destructor. Remember the constructor must initialize all the data members including those inherited from Event class.
  • Define the member function prototypes for setters/getters for title data member and only getters for artList and numArtifacts data members.
  • Redefine toString function.

Step 2. Implement Exhibit.cpp (60 points)

  • Start with including the header file Exhibit.h. You will also need other libraries such as sstream and string libraries.
  • Implement constructor: The constructor must call Event constructor to initialize the inherited data members. In the body of the constructor, you must set the newly introduced data members.
  • Implement destructor: Empty body
  • Implement setters and getters: Implement the functions that you defined in Exhibit.h
  • Implement toString(): This function must call Event class toString function as well as Artifact class toString functions in order to produce the following sample format:

Output:

Exhibit title: Rulers of Egypt

Start date: 3/5/2021

End Date: 3/7/2021

Location: Coates Hall

Artifacts:

Artifact name: Sarcophagus of King Tut

Origin: Ancient Egypt

Era: 1000 BC

Artifact name: Tiara of Cleopatra

Origin: Ancient Egypt

Era: 500 BC

Step 3: Test your class with the following main function code.

Main.cpp

#include "Exhibit.h"

#include

#include

using namespace std;

int main()

{

Artifact a1{"Sarcophagus of King Tut", "Ancient Egypt", "1000 BC"};

Artifact a2{"Tiara of Cleopatra", "Ancient Egypt", "500 BC"};

Artifact * list = new Artifact[2]{};

list[0] = a1;

list[1] = a2;

Exhibit myexhibit{"3/5/2021", "3/7/2021", "Coates Hall", "Rulers of Egypt", list, 2};

cout << "EXHIBIT: " << endl;

cout << myexhibit.toString() << endl;

delete [] list;

return 0;

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!