I have a scenario about railway system. In this system there are
•Normal : The rails don’t have any extern support.
•Electrified : The rails supported with electricity.
•High-Speed Train :This type of trains track on electrified rails.
•Passanger Train : Passanger trains can move either electrified or normal rails.
•Accelerated Passenger Train : This type of trains track on electrified rails. It is evolved from Passenger Train .
•Goods Train : A goods train can move both of rails but its weight makes it harmful for electrified rails. So it is not preffered.
I want to show the relation between trains and rails using uml. Obviously trains dont have rails. They just use them.
So here is how I made it:
I created an abstract class called “Rail”. Then derived 2 sub-classes “Normal” and “Electrified”. Created abstract class “Train”, derived sub-classes “HighSpeedTrain”, “PassengerTrain”, “GoodsTrain”. Also "AcceleratedPassengerTrain derives from “PassengerTrain”.
Then I used dependency to connect classes.
But im not sure if it’s true. Another problem; “AcceleratedPassengerTrain” should only use electrified rail. In my solution, I think it also supports normal rail because it inherits from “PassengerTrain”. Please tell me what do you think about the design. Thanks for your help.