Created
June 29, 2020 09:46
-
-
Save AbhinavPradeep/5ae445fc16a41aaf45156461afe02ba9 to your computer and use it in GitHub Desktop.
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
using System; | |
using System.Threading; | |
namespace MultiThreadedProgramming | |
{ | |
class Account | |
{ | |
public Account() | |
{ | |
Balance = 0.00; | |
} | |
public Double Balance{get; private set;} | |
public void Withdraw(double Amount) | |
{ | |
System.Console.WriteLine($"Trying to withdraw ${Amount}"); | |
if (Balance >= Amount) | |
{ | |
Thread.Sleep(10000); | |
Balance -= Amount; | |
System.Console.WriteLine($"Balance left after withdrawl = ${Balance}"); | |
} | |
else | |
{ | |
System.Console.WriteLine($"Sorry you only have ${Balance} left"); | |
} | |
} | |
public void Deposit(double Amount) | |
{ | |
Balance+= Amount; | |
System.Console.WriteLine($"Balance = ${Balance}"); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment