Write a C++ program to implement inheritance by accessing the base class constructor in the derived classes. Strictly adhere to the Object-Oriented specifications given in the problem statement. All class names, member variable names, and function names should be the same as specified in the problem statement. The class Event has the following protected attributes
Write a C++ program to implement inheritance by accessing the base class constructor in the derived classes.
Strictly adhere to the Object-Oriented specifications given in the problem statement. All class names, member variable names, and function names should be the same as specified in the problem statement.
The class Event has the following protected attributes
Data type | Variable |
string | name |
string | detail |
string | type |
string | organiser |
Define the mentioned protected attributes in the Event class.
Define default constructor and a constructor with parameters passed in the same order as declared in the class and include appropriate getters and setters.
The derived class Exhibition derived from Event class has the following private attributes
Data type | Variable |
int | numberOfStalls |
Define the mentioned private attribute in the Exhibition class.
Define default constructor and a constructor with parameters passed in the same order given below
Exhibition(String name, String detail, String type, String organiser, Integer numberOfStalls) and include appropriate getters and setters.
Include the following public member function in the class Exhibition
Method name | Description |
void display() | This method displays the details of the Exhibition |
The derived class StageEvent derived from the Event class has the following private attributes
Data type | Variable |
int | numberOfSeats |
Define the mentioned private attribute in the StageEvent class.
Define default constructor and a constructor with parameters passed in the same order given below
StageEvent(String name, String detail, String type, String organiser, Integer numberOfSeats) and include appropriate getters and setters.
Include the following public member function in the class StageEvent
Method name | Description |
void display() | This method displays the details of the StageEvent |
In the Main method, inputs from the user are obtained and the objects for StageEvent or Exhibition class are created and invoked display methods to display the details.
Input and Output format:
Refer sample input and output for formatting specifications.
Sample Input and Output 1
Choose Event type
1.Exhibition
2.Stage Event
1
Enter the details of Exhibition in CSV format
BookExpo,SpecialSale,Academics,John,12
Name : BookExpo
Detail : SpecialSale
Type : Academics
Organiser : John
Number of Stalls : 12
Sample Input and Output 2:
Choose Event type
1.Exhibition
2.Stage Event
2
Enter the details of Stage Event in CSV format
MagicalShow,NewYearSpecial,Magic,Robert,55
Name : MagicalShow
Detail : NewYearSpecial
Type : Magic
Organiser : Robert
Number of Seats : 55
Sample Input and Output 3:
Choose Event type
1.Exhibition
2.Stage Event
3
Invalid choice
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 7 images