This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Sukhpinder : ICelebrityInstagram | |
{ | |
private readonly List<IFollower> _posts = new List<IFollower>(); | |
private string _post; | |
public string FullName => "Sukhpinder Singh"; | |
public string Post { | |
get { return _post; } | |
set | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Follower : IFollower | |
{ | |
public void Update(ICelebrityInstagram celebrityInstagram) | |
{ | |
Console.WriteLine($"Follower notified. Post of {celebrityInstagram.FullName}: " + | |
$"{celebrityInstagram.Post}"); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static void Main(string[] args) | |
{ | |
IVehicleAggregate car = new Vehicles.Car(); | |
IVehicleAggregate motercycle = new Vehicles.Motercycle(); | |
IVehicleIterator carIterator = car.CreateIterator(); | |
IVehicleIterator motercycleIterator = motercycle.CreateIterator(); | |
PrintVehicles(carIterator); | |
PrintVehicles(motercycleIterator); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Motercycle : IVehicleAggregate | |
{ | |
private string[] _motercycles; | |
public Motercycle() | |
{ | |
_motercycles = new[] { "Bike 1", "Bike 2", "Bike 3" }; | |
} | |
public IVehicleIterator CreateIterator() | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Car : IVehicleAggregate | |
{ | |
private List<string> _cars; | |
public Car() | |
{ | |
_cars = new List<string> { "Car 1", "Car 2", "Car 3" }; | |
} | |
public IVehicleIterator CreateIterator() | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MotercycleIterator : IVehicleIterator | |
{ | |
private string[] _motercylces; | |
private int _current; | |
public MotercycleIterator(string[] motercylces) | |
{ | |
_motercylces = motercylces; | |
_current = 0; | |
} | |
public string Current() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class CarIterator : IVehicleIterator | |
{ | |
private List<string> _cars; | |
private int _current; | |
public CarIterator(List<string> cars) | |
{ | |
_cars = cars; | |
_current = 0; | |
} | |
public string Current() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static void Main(string[] args) | |
{ | |
Car car = new SmallCar(); | |
Console.WriteLine($"Price of car {car.GetName()} : " + car.CarPrice()); | |
var car1 = new Sunroof(car); | |
Console.WriteLine($"Price of car {car1.GetName()} : " + car1.CarPrice()); | |
var car2 = new AdvanceMusic(car); | |
Console.WriteLine($"Price of car {car2.GetName()} : " + car2.CarPrice()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Sunroof : CarDecorator | |
{ | |
public Sunroof(Car car) : base(car) | |
{ | |
} | |
public override int CarPrice() => _car.CarPrice() + 2000; | |
public override string GetName() => "Alto Lxi with Sunroof"; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class AdvanceMusic : CarDecorator | |
{ | |
public AdvanceMusic(Car car) : base(car) | |
{ | |
} | |
public override int CarPrice() => _car.CarPrice() + 3000; | |
public override string GetName()=> "Alto Lxi with advance music system"; | |
} |