This file contains hidden or 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 abstract class AChatroom | |
{ | |
public abstract void Register(User user); | |
public abstract void Post(string fromUser, string toUser, string msg); | |
} |
This file contains hidden or 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
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
ITransactions adapter = new TransAdapter(); | |
foreach (var item in adapter.GetTransactions()) | |
{ | |
Console.WriteLine(item); | |
} | |
} |
This file contains hidden or 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 TransAdapter : OrgYTransactions, ITransactions | |
{ | |
public List<string> GetTransactions() | |
{ | |
return GetTransactionsList(); | |
} | |
} |
This file contains hidden or 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 OrgYTransactions | |
{ | |
public List<string> GetTransactionsList() | |
{ | |
List<string> transactions = new List<string>(); | |
transactions.Add("Debit 1"); | |
transactions.Add("Debit 2"); | |
transactions.Add("Debit 3"); | |
return transactions; | |
} |
This file contains hidden or 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) | |
{ | |
var sedan = new ModelSedan(); | |
var suv = new ModelSuv(); | |
var factory = new CarFactory(); | |
var builders = new List<CarBuilder> { suv, sedan }; | |
foreach (var b in builders) | |
{ |
This file contains hidden or 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 ModelSedan : CarBuilder | |
{ | |
public override void SetIsSUV() | |
{ | |
_car.IsSUV = false; | |
} | |
public override void SetName() | |
{ | |
_car.Name = "Maruti Sedan"; |
This file contains hidden or 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 ModelSuv : CarBuilder | |
{ | |
public override void SetIsSUV() | |
{ | |
_car.IsSUV = true; | |
} | |
public override void SetName() | |
{ | |
_car.Name = "Maruti SUV"; |
This file contains hidden or 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 CarFactory | |
{ | |
public Car Build(CarBuilder builder) | |
{ | |
builder.SetName(); | |
builder.SetSpeed(); | |
builder.SetIsSUV(); | |
return builder.GetCar(); | |
} | |
} |
This file contains hidden or 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 abstract class CarBuilder | |
{ | |
protected readonly Car _car = new Car(); | |
public abstract void SetName(); | |
public abstract void SetSpeed(); | |
public abstract void SetIsSUV(); | |
public virtual Car GetCar() => _car; | |
} |
This file contains hidden or 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) | |
{ | |
var sukhpinder = new Sukhpinder(); | |
var firstFan = new Follower(); | |
var secondFan = new Follower(); | |
sukhpinder.AddFollower(firstFan); | |
sukhpinder.AddFollower(secondFan); |