Download Source(23,52 kb)
We have different kind of vehicle implementations inherited from an abstract Vehicle class. Our code looks like this
001 //Abstract Vehicle class
002
003 public abstract class Vehicle
004
005 {
006
007 public abstract string Description { get; }
008
009
010
011 }
012
013
014
015 //Concrete implementation
016
017 public sealed class Car : Vehicle
018
019 {
020
021 public override string Description
022
023 {
024
025 get { return "Car"; }
026
027 }
028
029 }
030
031
032
033 //Concrete implementation
034
035 public sealed class Helicopter : Vehicle
036
037 {
038
039 public override string Description
040
041 {
042
043 get { return "Helicopter"; }
044
045 }
046
047 }
048
049
050
051 //Concrete implementation
052
053 public sealed class Jet : Vehicle
054
055 {
056
057 public override string Description
058
059 {
060
061 get { return "Jet"; }
062
063 }
064
065 }
Suppose that our client wants to rent these different kind of vehicles and print vehicle information plus rental specific info such as FromDate, ToDate and the customer's name. We could implement this requirement by adding those new properties to our base Vehicle class in order to meet our customer's need. We also have to modify our concrete Vehicle classes so thet they can provide rental information through their Description property.
Here is our modified Vehicle class More...
d8a0c731-e8eb-41e6-8768-4473c8b233f3|1|4.0