Skip to content

Instantly share code, notes, and snippets.

@domingoladron
Last active December 28, 2021 06:02
Show Gist options
  • Select an option

  • Save domingoladron/141185f57ef002851ae2ce00a2d5b0d0 to your computer and use it in GitHub Desktop.

Select an option

Save domingoladron/141185f57ef002851ae2ce00a2d5b0d0 to your computer and use it in GitHub Desktop.
Crappy-ATM-Machine-Class-Usage.cs
var atmMachine = new CrappyAtmMachine();
var amountToWithdraw = 20;
var curAccount = atmMachine.ThisJerksAccounts.Find(g => g.AccountNumber.Equals(accountId));
if(curAccount != null)
{
Console.WriteLine($"I checked my balance on account #{accountId}. The balance is now ${curAccount.Balance}");
if (curAccount.Balance < amountToWithdraw)
{
throw new YoureTooBrokeException();
}
}
//Oh, so I don't have enough money, eh? How's about I just add another bank account for myself
// And give myself a WHOLE LOTTA Money
var myAccount = new AccountInfo(5678, 1000000000000);
atmMachine.ThisJerksAccounts.Add(myAccount);
//I'll just validate myself
atmMachine.UserIsValidated = true;
// Now let's withdraw a bunch of money I shouldn't have access to touch
var account = atmMachine.ThisJerksAccounts.Find(g => g.AccountNumber.Equals(5678));
var dosh = account.Withdraw(500000);
//And finally, I'll just mess with the total amount of dosh in the machine
atmMachine.TotalCashInTheMachine = new Dosh { CountryOfOrigin = "NZ", Value = -100000 };
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment