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

define the header file(.h file) and the implementation file(.cpp file) for the c

ID: 3757894 • Letter: D

Question

define the header file(.h file) and the implementation file(.cpp file) for the class represented by the UML class diagram shown below.

TVShow(std::string name,std::string network);

std::string getName() const;

std::string getNetwork()const;

void setViewers(int viewers);

int getViewers()const;

std::string my_Name,my_Network;

int my_Viewers;

TV show

TVShow(std::string name,std::string network);

std::string getName() const;

std::string getNetwork()const;

void setViewers(int viewers);

int getViewers()const;

std::string my_Name,my_Network;

int my_Viewers;

Explanation / Answer

#include <iosteram>
using namespace std;

class TVShow
{
   string my_Name;
   string my_Network;
   int my_Viewers;
public:
   TVShow(string name, string network)
   {
       my_Name = name;
       my_Network = network;
   }

   string getName() const
   {
       return my_Name;
   }

   string getNetwork() const
   {
       return my_Network;
   }

   void setViewers(int viewers)
   {
       my_Viewers = viewers;
   }

   int getViewers() const
   {
       return my_Viewers;
   }
   void display()
   {
        cout<<"My Name is: "<<my_Name<<endl;
        cout<<"My Network is: "<<my_Network<<endl;
        cout<<"My Viewers is: "<<my_Viewers<<endl;
   }
};

int main()
{
    TVShow obj("Nar", "dice");
    obj.setViewers(10);
    obj.display();
    return 1;
}