Answer to Question #259675 in Python for Anahu

Question #259675

Write a program that has a class Train with data members-no_of seats_sleeper, no_ of_seats_2Tier, no_of_seats_3Tier and member functions to set and display data. Derive a class Reservation that has data members-seats_Booked_sleeper, , no_ of_seats_Booked_2Tier, no_of_seats_Booked_3Tier, and a functions to book and cancel tickets, and display status

1
Expert's answer
2021-11-01T18:50:37-0400
#include <iostream>




using namespace std;


class Train{
	private:
	int no_of_seats_sleeper, no_of_seats_2Tier, no_of_seats_3Tier;
	public:
		void setData(){
			cout<<"Enter number of seats sleeper:\n";
			int sleaper;
			cin>>sleaper;
			cout<<"Enter the number of seats in tier 2:\n";
			int tier2;
			cin>>tier2;
			cout<<"Enter the number of seats in tier 3:\n";
			int tier3;
			cin>>tier3;
			no_of_seats_sleeper = sleaper;
			no_of_seats_2Tier = tier2;
			no_of_seats_3Tier = tier3;
			
		}
		void output(){
 cout<<"Number of seats in sleeper: "<< no_of_seats_sleeper<<endl;
 cout<<"Number of seats in tier 2: "<<no_of_seats_2Tier<<endl;
 cout<<"Number of seats in tier 3"<< no_of_seats_3Tier<<endl;
 }
 
 void bookSeat(){
 cout<<"\nSeat booked successfully\n";
 }
 void cancelSeat(){
 cout<<"\nSeat Cancelled successfully\n";
 }
};


class Reservation:public Train{
	private:
		int seats_Booked_sleeper, no_of_seats_Booked_2Tier, no_of_seats_Booked_3Tier;
	public:
		
		void input(){
			cout<<"Enter number of seats booked in sleeper:\n";
			int sleaper;
			cin>>sleaper;
			cout<<"Enter the number of seats booked in tier 2:\n";
			int tier2;
			cin>>tier2;
			cout<<"Enter the number of seats booked in tier 3:\n";
			int tier3;
			cin>>tier3;
			seats_Booked_sleeper = sleaper;
			no_of_seats_Booked_2Tier = tier2;
			no_of_seats_Booked_3Tier = tier3;
			
		}
		void display(){
 cout<<"Number of seats booked in sleeper: "<< seats_Booked_sleeper<<endl;
 cout<<"Number of seats booked in tier 2: "<<no_of_seats_Booked_2Tier<<endl;
 cout<<"Number of seats booked in tier 3"<<no_of_seats_Booked_3Tier<<endl;
 }
 
  void bookSeat(){
 cout<<"\nSeat booked successfully!!";
 }
 void cancelSeat(){
 cout<<"\nSeat Cancelled successfully!!";
 }	
		
	
}; 


int main(){
	
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog