Publicité

Can someone please help me with this C++ code I will give thumbs up.pdf

1 Apr 2023
Can someone please help me with this C++ code I will give thumbs up.pdf
Can someone please help me with this C++ code I will give thumbs up.pdf
Can someone please help me with this C++ code I will give thumbs up.pdf
Prochain SlideShare
Project02 witProject02 wit
Chargement dans ... 3
1 sur 3
Publicité

Contenu connexe

Plus de sales88(20)

Publicité

Can someone please help me with this C++ code I will give thumbs up.pdf

  1. Can someone please help me with this C++ code? I will give thumbs up for sure. 1- The Media interface Create the following two Pure virtual functions: a pure virtual function is a virtual function that has no implementation. To indicate that the pure virtual function does not have an implementation, set its prototype to zero (= 0;) in the class declaration. play Returns reference to ostream and receives a reference to ostream as an argument. This pure virtual function can not modify the current object. load Returns void and receives a reference to istream as an argument. destructor Create a virtual empty destructor for the Media interface. this guarantees that any dynamically allocated derived class from the Media interface pointed by a base class pointer will be removed properly from memory when deleted. Media helper functions Overload the insertion and extraction operators (using play and load functions) so any Media object can be written or read using ostream and istream. 2- The Video Abstract Class Inherit an abstract class from the interface Media called Video. This class represents a Video- Media with a specific duration of playback. This class will implement the pure virtual function load but will not implement the play function; therefore it remains abstract. Private Member variable Add an integer type member m_length which defines the length of the video. Protected members get() Add a query called get that returns the value of the m_length member variable. This query can not change the status of a Video. public members Default (no argument) constructor Sets the m_length to 0. One argument constructor Set the m_length value to the incoming argument. If the length value is invalid (negative) the video will be set to be empty
  2. deleted actions The copy constructor and assignment operator are deleted to prevent copying or assignment of instances of this class. load Reads the length from the istream and sets the data member, assuming that the length value is comma ',' terminated. (The terminating comma should be extracted from the istream) other methods You can add any other methods if needed, to accomplish the above. 3- The VRVideo concrete class VRVideo (Virtual Reality Video) inherits the Video class to create a VRVideo. This class adds an equipment name to the Video class (for example: "Oculus Rift headset") Private Member variable Create a member pointer variable called m_equipment to hold the dynamically allocated C-string specifying the special equipment required for VRVideo. Default (no argument) constructor Sets the m_equipment member variable to a null pointer and defaults the Base class Video. Two argument constructor Receives the Video length and a C-string for the name of the equipment. The video length is used to initialize the Base class (Video) and a copy of the name of equipment is kept Dynamically by the m_equipment attribute. If either the length or the equipment name is invalid, then VRvideo will be set to empty. Destructor Deallocates the m_equipment dynamic C-string. load Reads comma-separated specs of the VRVideo from istream. This function overrides the load function of the base class as follows. First, it will call the load function of the base class and then reads the C-string until newline (n)and ignores newline. Afterward, follow the same logic as was done in the two-argument constructor but make sure the m_equipment is deallocated before overwriting the newly allocated memory. play This function overrides the play function of the base class. If the VRVideo is not empty, this function will first print the VRVideo requires followed by m_equipement and then go to the new line. It then prints Video Length = followed by get() of the base, Video class Otherwise, it will take no action.
  3. For the exact output format, look at the execution sample. 4- The Animation concrete class The Animation class inherits the Video class to create an Animation video in 2 or 3 dimensions. Private Member variable Create an int variable m_dimension to hold the dimension of the Animated video. Default (no argument) constructor Sets m_dimension to 0 and defaults the base class. Two argument constructor Receives two arguments; an int type for the m_length and another int type for the m_dimension of the Animation from the argument list. Passes the appropriate data to the constructor of the base class and sets the m_dimension member variable to the corresponding value received from the argument list. However, the m_dimension should be either 2 or 3. If validation fails set Animation to empty. load Reads comma-separated specs of the Animation from istream. This function overrides the load function of the base class as follows. First, it will call the load function of the base class, then it will read the value of the m_dimention from the istream and then ignores the rest of the characters up to and including the newline character ('n'). The same validation will be applied to the data as in the constructor. play This function overrides the play function of the base class. If the Animation is not empty, this function will first print Animation is in followed by m_dimension followed by -D . It then prints Video Length = followed by get(). Otherwise, it will take no action. For the exact output format, look at the execution sample. main.cpp = https://github.com/Seneca-244200/OOP-Workshops/blob/main/WS08/lab/main.cpp correct Output= https://github.com/Seneca-244200/OOP- Workshops/blob/main/WS08/lab/correct_output.txt Thanks.
Publicité