static void Main(string[] args) { var sav1 = new Savings(0.01); // sav1.Debug(); var sav2 = new Savings(); //create interestaccount /*var int1 = new InterestAccount(); * // int1.Debug(); * * var int2 = new InterestAccount(0.12); * int2.Deposit(100); * int2.CalculateInterest(3); * //int2.Debug();*/ //test data var chk1 = new Checking(); chk1.Deposit(100.25m); chk1.Withdrawl(75.00m); chk1.Deposit(-10); chk1.Withdrawl(1000.00m); chk1.Deposit(0); chk1.Withdrawl(100.00m); var chk2 = new Checking(); chk2.Deposit(200); chk2.Withdrawl(40); chk1.Debug(); chk2.Debug(); //transfer from checking 1 to checking 2 chk2.Transfer(100, chk1);//give param of transfer into //chk1.Debug(); //chk2.Debug(); //polymorphism create a collection var accounts = new List <Account>(); accounts.Add(sav1); //accounts.Add(int1); //accounts.Add(chk1); //accounts.Add(chk2); accounts.Add(sav1); foreach (var account in accounts) { Console.WriteLine(account); } }
static void Main(string[] args) { var sav1 = new Savings(0.01); sav1.Debug(); var int1 = new InterestBearing(0.12); int1.Deposit(100); int1.CalculateInterest(3); int1.Debug(); var chk1 = new Checking(); chk1.Deposit(100); chk1.Withdraw(75); chk1.Deposit(-10); chk1.Withdraw(1000); chk1.Deposit(0); chk1.Withdraw(100); var chk2 = new Checking(); chk2.Deposit(200); chk1.Withdraw(40); // chk1.Debug(); // chk2.Debug(); chk2.Transfer(100, chk1); // chk1.Debug(); // chk2.Debug(); var accounts = new List <Account>(); //accounts.Add(chk1); //accounts.Add(chk2); accounts.Add(sav1); accounts.Add(int1); foreach (var account in accounts) { Console.WriteLine(account); } }
static void Main(string[] args) { var sav1 = new Savings(0.01); sav1.Debug(); var int1 = new InterestAccount(0.12); int1.Deposit(100); int1.CalculateInterest(3); int1.Debug(); // 'm' means treat as a decimal var Chk1 = new Checking(); Chk1.Deposit(100); Chk1.Withdraw(75); Chk1.Deposit(-10); Chk1.Withdraw(1000); Chk1.Deposit(0); Chk1.Withdraw(100); var Chk2 = new Checking(); Chk2.Deposit(200); Chk2.Withdraw(40); //Chk1.Debug(); //Chk2.Debug(); Chk2.Transfer(100, Chk1); //Chk1.Debug(); //Chk2.Debug(); var accounts = new List <Account>(); accounts.Add(sav1); accounts.Add(int1); //accounts.Add(Chk2); //accounts.Add(Chk1); }
static void Main(string[] args) { var chk1 = new Checking(); chk1.Deposit(150); chk1.Withdraw(10); chk1.WriteCheck("Cash", 10, 101); chk1.WriteCheck("Apple", 2); var sav1 = new Savings(); sav1.InterestRate(0.12); sav1.Deposit(100); sav1.CalculateAndDepositInterest(300); Console.WriteLine($"Balance is {sav1.GetBalance()}"); Console.WriteLine($"Routing number is {Account.GetRoutingNumber()}"); var acct1 = new Account(); acct1.Deposit(100000); acct1.Withdraw(60000); acct1.Withdraw(50000); acct1.Deposit(-20000); acct1.Withdraw(-10000); var acct2 = new Account(); acct1.Transfer(acct2, 1000); acct1.Transfer(acct2, 40000); acct1.Transfer(acct2, 5000); Account.AddAccount(acct1); Account.AddAccount(acct2); Account.AddAccount(sav1); Account.ListAccounts(); sav1.Withdraw(278); Account.ListAccounts(); }
public void Main(string[] args) { #region Accounts Object - Cannot be created are it is Marked as an Abstract Class //var accountObj = new Accounts() { AccountNumber = 101, AccountBalance = 5000, AccountName = "Nikhil", AccountType = "Savings" }; //try //{ // Console.WriteLine(accountObj.Widraw(300)); //} //catch (Exception expObj) //{ // Console.WriteLine(expObj.Message); //} #endregion Console.WriteLine("~~~~~~~~~~~~~~ Welcome to Banking ~~~~~~~~~~~~~~~"); //Console.WriteLine("Please Choose from the Option"); //Console.WriteLine("1. Create New Account"); //Console.WriteLine("2. Widraw"); //Console.WriteLine("3. Deposit"); //Console.WriteLine("4. Exit"); int menuOptionSelected = 0; int accountType = 0; Savings savObj = null; Current currObj = null; PF pfObj = null; int widrawAmount = 0; int depositAmount = 0; int continueMore = 1; while (continueMore == 1) { Console.WriteLine("Please Choose from the Option"); Console.WriteLine("1. Create New Account"); Console.WriteLine("2. Widraw"); Console.WriteLine("3. Deposit"); Console.WriteLine("4. Exit"); menuOptionSelected = Convert.ToInt32(Console.ReadLine()); switch (menuOptionSelected) { #region Open New Account case 1: Console.WriteLine("Which Account You Wish To Open"); Console.WriteLine("1. Savings"); Console.WriteLine("2. Current"); Console.WriteLine("3. PF"); accountType = Convert.ToInt32(Console.ReadLine()); if (accountType == 1) { savObj = new Savings() { AccountNumber = 101, AccountBalance = 5000, AccountName = "Nikhil" }; Console.WriteLine("Savings Account Created With Default values "); Console.WriteLine("Account Number : " + savObj.AccountNumber); Console.WriteLine("Account Name : " + savObj.AccountName); Console.WriteLine("Account Type : " + savObj.AccountType); Console.WriteLine("Account Balance : " + savObj.AccountBalance); } else if (accountType == 2) { currObj = new Current() { AccountNumber = 102, AccountBalance = 5000, AccountName = "Karan" }; Console.WriteLine("Current Account Created With Default values "); Console.WriteLine("Account Number : " + currObj.AccountNumber); Console.WriteLine("Account Name : " + currObj.AccountName); Console.WriteLine("Account Type : " + currObj.AccountType); Console.WriteLine("Account Balance : " + currObj.AccountBalance); } else if (accountType == 3) { pfObj = new PF() { AccountNumber = 103, AccountBalance = 25000, AccountName = "Sahil" }; Console.WriteLine("Current Account Created With Default values "); Console.WriteLine("Account Number : " + currObj.AccountNumber); Console.WriteLine("Account Name : " + currObj.AccountName); Console.WriteLine("Account Type : " + currObj.AccountType); Console.WriteLine("Account Balance : " + currObj.AccountBalance); } else { Console.WriteLine("Sorry Invalid Account Type, please try Again"); } break; #endregion #region Widraw case 2: Console.WriteLine("Choose the Account Type"); Console.WriteLine("1. Savings"); Console.WriteLine("2. Current"); Console.WriteLine("3. PF"); accountType = Convert.ToInt32(Console.ReadLine()); if (accountType == 1) { if (savObj == null) { savObj = new Savings() { AccountNumber = 101, AccountBalance = 5000, AccountName = "Nikhil" }; Console.WriteLine("Account Created with Default values "); } try { Console.WriteLine("Avaialble Balance in Your Account Number 101 : " + savObj.AccountBalance); Console.WriteLine("Enter the Amount to Widraw"); widrawAmount = Convert.ToInt32(Console.ReadLine()); savObj.Widraw(widrawAmount); Console.WriteLine("Balance After Widrawal " + savObj.AccountBalance); } catch (Exception expObj) { Console.WriteLine(expObj.Message); } } else if (accountType == 2) { if (currObj == null) { currObj = new Current() { AccountNumber = 102, AccountBalance = 5000, AccountName = "Karan" }; } Console.WriteLine("Avaialble Balance in Your Account Number 101 : " + currObj.AccountBalance); try { Console.WriteLine("Enter the Amount to Widraw"); widrawAmount = Convert.ToInt32(Console.ReadLine()); currObj.Widraw(widrawAmount); Console.WriteLine("Balance After Widrawal " + currObj.AccountBalance); } catch (Exception expObj) { Console.WriteLine(expObj.Message); } } else if (accountType == 3) { if (pfObj == null) { pfObj = new PF() { AccountNumber = 103, AccountBalance = 25000, AccountName = "Sahil" }; } Console.WriteLine("Avaialble Balance in Your Account Number 101 : 25000"); try { Console.WriteLine("Enter the Amount to Widraw"); widrawAmount = Convert.ToInt32(Console.ReadLine()); pfObj.Widraw(widrawAmount); Console.WriteLine("Balance After Widrawal " + pfObj.AccountBalance); } catch (Exception expObj) { Console.WriteLine(expObj.Message); } } else { Console.WriteLine("Sorry Invalid Account Type, please try Again"); } break; #endregion #region Deposit case 3: Console.WriteLine("Choose the Account Type"); Console.WriteLine("1. Savings"); Console.WriteLine("2. Current"); Console.WriteLine("3. PF"); accountType = Convert.ToInt32(Console.ReadLine()); if (accountType == 1) { if (savObj == null) { savObj = new Savings() { AccountNumber = 101, AccountBalance = 5000, AccountName = "Nikhil" }; Console.WriteLine("Account Created with Default values "); } try { Console.WriteLine("Avaialble Balance in Your Account Number 101 : " + savObj.AccountBalance); Console.WriteLine("Enter the Amount to Deposit"); depositAmount = Convert.ToInt32(Console.ReadLine()); savObj.Deposit(depositAmount); Console.WriteLine("Balance After Deposit " + savObj.AccountBalance); } catch (Exception expObj) { Console.WriteLine(expObj.Message); } } else if (accountType == 2) { if (currObj == null) { currObj = new Current() { AccountNumber = 102, AccountBalance = 5000, AccountName = "Karan" }; } Console.WriteLine("Avaialble Balance in Your Account Number 101 : " + currObj.AccountBalance); depositAmount = Convert.ToInt32(Console.ReadLine()); try { Console.WriteLine("Enter the Amount to Deposit"); depositAmount = Convert.ToInt32(Console.ReadLine()); currObj.Deposit(depositAmount); Console.WriteLine("Balance After Deposit " + currObj.AccountBalance); } catch (Exception expObj) { Console.WriteLine(expObj.Message); } } else if (accountType == 3) { if (pfObj == null) { pfObj = new PF() { AccountNumber = 103, AccountBalance = 25000, AccountName = "Sahil" }; } Console.WriteLine("Avaialble Balance in Your Account Number 101 : " + pfObj.AccountBalance); try { Console.WriteLine("Enter the Amount to Deposit"); depositAmount = Convert.ToInt32(Console.ReadLine()); pfObj.Deposit(depositAmount); Console.WriteLine("Balance After Deposit " + pfObj.AccountBalance); } catch (Exception expObj) { Console.WriteLine(expObj.Message); } } else { Console.WriteLine("Sorry Invalid Account Type, please try Again"); } break; #endregion default: Console.WriteLine("Sorry Invalid Menu Option"); break; } Console.WriteLine(" ---------------------------------- "); Console.WriteLine("Do you Want to Continue ? "); Console.WriteLine("1. Yes"); Console.WriteLine("2. No"); continueMore = Convert.ToInt32(Console.ReadLine()); Console.WriteLine(" ---------------------------------- "); } Console.WriteLine(" Thank You For Banking with Us "); }