works on mobile browsers too
references:
https://github.com/mharrys/fluids-2d
Inspired by https://codepen.io/nhembram
works on mobile browsers too
references:
https://github.com/mharrys/fluids-2d
Inspired by https://codepen.io/nhembram
ClaimApprover junior = new Manager(); | |
ClaimApprover sukhpinder = new Manager(); | |
ClaimApprover singh = new SeniorManager(); | |
junior.SetHierarchy(sukhpinder); | |
sukhpinder.SetHierarchy(singh); | |
Claim c1 = new Claim() { amount = 999, Id = 1001 }; | |
Claim c2 = new Claim() { amount = 10001, Id = 1002 }; | |
junior.ApproveRequest(c1); |
public class SeniorManager : ClaimApprover | |
{ | |
public override void ApproveRequest(Claim claim) | |
{ | |
if (claim.amount > 1000 && claim.amount <= 10000) | |
{ | |
System.Console.WriteLine($"Claim reference {claim.Id} with amount {claim.amount} is approved by Senior Manager"); | |
} | |
else | |
{ |
public class Manager : ClaimApprover | |
{ | |
public override void ApproveRequest(Claim claim) | |
{ | |
if (claim.amount >= 100 && claim.amount <= 1000) | |
{ | |
System.Console.WriteLine($"Claim reference {claim.Id} with amount {claim.amount} is approved by Manager"); | |
} | |
else if (claimApprover != null) | |
{ |
public class Junior : ClaimApprover | |
{ | |
public override void ApproveRequest(Claim claim) | |
{ | |
System.Console.WriteLine("Cannot approve"); | |
} | |
} |
public abstract class ClaimApprover | |
{ | |
protected ClaimApprover claimApprover; | |
public void SetHierarchy(ClaimApprover claimApprover) | |
{ | |
this.claimApprover = claimApprover; | |
} | |
public abstract void ApproveRequest(Claim claim); | |
} |
static void Main(string[] args) | |
{ | |
Chatroom chatroom = new Chatroom(); | |
User Jennifer = new UserPersona(Username.Jennifer.ToString()); | |
User Ashley = new UserPersona(Username.Ashley.ToString()); | |
User David = new UserPersona(Username.David.ToString()); | |
User Scott = new UserPersona(Username.Scott.ToString()); | |
chatroom.Register(Jennifer); | |
chatroom.Register(Ashley); |
class UserPersona : User | |
{ | |
public UserPersona(string name) : base(name) { } | |
public override void DM(string from, string message) => base.DM(from, message); | |
} |
public class User | |
{ | |
private Chatroom _chatroom; | |
private string _name; | |
public User(string name) => this._name = name; | |
public string Name => _name; | |
public Chatroom Chatroom | |
{ |
public class Chatroom : AChatroom | |
{ | |
private Dictionary<string, User> _users = new Dictionary<string, User>(); | |
public override void Post(string fromUser, string toUser, string msg) | |
{ | |
User participant = _users[toUser]; | |
if (participant != null) | |
{ | |
participant.DM(fromUser, msg); |