Create a class Train (type(weekly/daily), train number, train
name) and inherit it in two classes Reserved_compartments (no of
compartments, no of seats, scost, category(AC/NonAC)) and
Unreserved_compartments (no of compartments, no of seats, scost).
Create another class named Train_Length that inherits the features
of Reserved_compartments and Unreserved_compartments along with
additional features (Total no of compartments, Total no of seating
capacity). Print the complete details of the Train_Length object
(along with total no of compartments, total no of seats and average
seat cost) to ensure that the duplicate copies of Train doesn’t
exist in Train_Length.
Note:-
Negative and zero input values are not allowed. All
attributes and methods should be public in all classes. Type of the
attributes and methods can be decided as per your requirements.
Example:-
Test cases:-
case=one
input=Weekly (train type)
1509 (train number)
Silambuexpress (train name)
12 (No of reserved compartments (RC))
1700 (No of seats)
254 (RC Seat cost)
AC (category)
3 (No of unreserved compartments (URC))
200 (No of seats)
125 (URC Seat cost)
output=Weekly (train type)
1509 (train number)
Silambuexpress (train name)
12 (No of reserved compartments (RC))
1700 (No of seats)
254 (RC Seat cost)
AC (category)
3 (No of unreserved compartments (URC))
200 (No of seats)
125 (URC Seat cost)
15 (Total no of compartments in this train)
1900 (Total no of seats in this train)
189.5 (Average seat cost in this train)
grade reduction=15%
case=two
input=Daily
1510
Nilagiriexpress
11
1600
-400
AC
2
150
200
output=Invalid
grade reduction=15%
case=three
input=Daily
1515
BlueMountain
12
1780
350
NonAC
3
-160
150
output=Invalid
grade reduction=15%
case=four
input=Daily
1512
Sabariexpress
10
1500
300
AC
2
200
175
output=Daily
1510
Sabariexpress
10
1500
300
AC
2
200
175
12
1700
237.5
grade reduction=15%
Create a class Train (type(weekly/daily), train number, train name) and inherit it in two classes Reserved_compartments
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am