Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- namespace BankingSystem
- {
- class Program
- {
- static void Main(string[] args)
- {
- ShowMainMenu();
- }
- public static void ShowMainMenu()
- {
- Console.Clear();
- Console.WriteLine("Weolcome to the Bank");
- Console.WriteLine("-------------------");
- Console.WriteLine("1: Create customer");
- Console.WriteLine("2: Show Customers");
- Console.WriteLine("-----------------");
- string command = Console.ReadLine();
- if (command == "1")
- {
- ShowCreateCustomer();
- }
- else if (command == "2")
- {
- ShowAllCustomers();
- }
- }
- public static void ShowAllCustomers()
- {
- Console.Clear();
- Console.WriteLine("----- All Customers -----");
- foreach (Customer myCustomer in Bank.AllCustomers)
- {
- Console.WriteLine("ID: " + myCustomer.Id + " Name: " + myCustomer.Name + " Money: " + myCustomer.Money);
- }
- Console.WriteLine("-----------");
- Console.WriteLine("1: Deposit, 2: Transfer, 3: Return to main");
- string command = Console.ReadLine();
- if (command == "1")
- {
- //deposit
- //first find the customer, then deposit the amount
- Console.Write("Enter the id of the customer: ");
- string customerId = Console.ReadLine();
- Console.Write("Enter the amount to deposit: ");
- string amount = Console.ReadLine();
- //now do the magic, find the customer then increase the money
- int theCustomerId = int.Parse(customerId);
- Customer myFoundCustomer = null;
- foreach (Customer c in Bank.AllCustomers)
- {
- if (c.Id == theCustomerId)
- {
- myFoundCustomer = c;
- break;
- }
- }
- //we might have found it
- if (myFoundCustomer != null)
- {
- myFoundCustomer.Money += float.Parse(amount);
- }
- ShowAllCustomers();
- }
- else if (command == "2")
- {
- TransferMoney();
- }
- else if (command == "3")
- {
- ShowMainMenu();
- }
- }
- public static void ShowCreateCustomer()
- {
- Console.Clear();
- Console.WriteLine("--- Create new Customer ---");
- Console.Write("Please enter the name: ");
- string name = Console.ReadLine();
- Console.Write("Please enter the id: ");
- string id = Console.ReadLine();
- Customer customer = new Customer();
- customer.Name = name;
- customer.Id = int.Parse(id);
- //add it to the bank
- Bank.AllCustomers.Add(customer);
- //create customer etc...
- //eventually return to main menu
- ShowMainMenu();
- }
- public static void TransferMoney()
- {
- Console.Clear();
- Console.WriteLine("--- Transfer Money ---");
- Console.Write("Please enter your account's ID: ");
- string id = Console.ReadLine();
- Console.Write("Please enter the Name of the person you would like to tranfer funds to: ");
- string name = Console.ReadLine();
- Console.Write("Enter the amount of funds you would like to transfer: ");
- string amount = Console.ReadLine();
- /*
- if (id == Customer.Id()) & (name == Customer.Name())
- {
- //transfer happens here
- }
- */
- ShowAllCustomers();
- }
- }
- }
- namespace BankingSystem
- {
- public class Bank
- {
- private static List<Customer> customers = new List<Customer>();
- public Bank()
- {
- customers = new List<Customer>();
- }
- public static List<Customer> AllCustomers
- {
- get
- {
- return customers;
- }
- }
- }
- }
- namespace BankingSystem
- {
- public class Customer
- {
- public Customer()
- {
- Money = 50;
- }
- public int Id { get; set; }
- public string Name { get; set; }
- public float Money { get; set; }
- }
- }
Add Comment
Please, Sign In to add comment