public void Information() //Promting the user with a menu to insert name and age { Console.WriteLine("Bank Register"); Console.Write("Name:"); string name = Console.ReadLine(); Console.Write("Age:"); int age = int.Parse(Console.ReadLine()); DebitCard debit = new DebitCard(name); Maestro maestro = new Maestro(name); Mastercard mastercard = new Mastercard(name); Visaelectron visaelectron = new Visaelectron(name); Visa visa = new Visa(name); if (age <= 18)//Only showing cards that are relevant for the users age { Cardform(debit); } if (age >= 18) { Cardform(visa); Cardform(maestro); } if (age >= 15) { Cardform(visaelectron); } Cardform(mastercard); }
static void Main(string[] args) { CardNumber cn = new CardNumber(); DateTime dt = DateTime.Now; Maestro mst = new Maestro("Ole", "Jensen", cn.CreateCNumber(14), dt.AddYears(3), "23", 18); DebitCard dbc = new DebitCard("Jørgen", "Hansen", cn.CreateCNumber(14), dt.AddYears(3), "23"); Electron ect = new Electron("Ulla", "Helstrup", cn.CreateCNumber(14), dt.AddYears(3), "23", 10000, 15); Visa via = new Visa("Ole", "Jensen", cn.CreateCNumber(14), dt.AddYears(3), "23", 20000, 25000, 18); Master mtr = new Master("Ole", "Jensen", cn.CreateCNumber(14), dt.AddYears(3), "23", 30000, 40000, 5000); Console.WriteLine("{0}{1}{2}{3}{4}", mst.FirstName, mst.LastName, mst.Cardnumber, mst.ExpirationDate, mst.Accountnumber); }
public Card CreateCard(CardType type) { Card card = new MasterCard(); int[] prefix; switch (type) { case CardType.Maestro: prefix = new int[4] { 5, 5, 5, 5 }; card = new Maestro("John", GenerateAccountNumber(), GeneratCardNumber(16, prefix)); break; case CardType.Mastercard: prefix = new int[2] { 5, 1 }; card = new MasterCard("John", GenerateAccountNumber(), GeneratCardNumber(16, prefix)); break; case CardType.Visa: prefix = new int[1] { 4 }; card = new Visa("John", GenerateAccountNumber(), GeneratCardNumber(16, prefix)); break; case CardType.VisaElectron: prefix = new int[4] { 4, 0, 2, 6 }; card = new VisaElectron("John", GenerateAccountNumber(), GeneratCardNumber(16, prefix)); break; case CardType.Debit: prefix = new int[4] { 2, 4, 0, 0 }; card = new Debit("John", GenerateAccountNumber(), GeneratCardNumber(16, prefix)); break; default: break; } return(card); }
static void Main(string[] args) { //Instantiere kortene VISAElectron ve = new VISAElectron("Christian Bøgh"); VISA v = new VISA("Christian Bøgh"); Mastercard mas = new Mastercard("Christian Bøgh"); Maestro mae = new Maestro("Christian Bøgh"); DebitCard d = new DebitCard("Christian Bøgh"); //Udskriver ToString metoden Console.WriteLine(ve.ToString()); Console.WriteLine(v.ToString()); Console.WriteLine(mas.ToString()); Console.WriteLine(mae.ToString()); Console.WriteLine(d.ToString()); //Pauser koden og venter på klikket på en tast Console.ReadKey(); }
static void Main(string[] args) { Console.WriteLine("Hello World!"); //create 3 new accounts Account a1 = new Account(CreateTestAccountsNum(), "a1"); Account a2 = new Account(CreateTestAccountsNum(), "a2"); Account a3 = new Account(CreateTestAccountsNum(), "a3"); //Create 3 cards 1 to each account Card mastercard = new MasterCard("Jens", a1); Card visa = new Visa("Erik", a2); Card maestro = new Maestro("Bo", a3); // Try to use all cards mastercard.Pay(false, 200.2); visa.Pay(false, 200.2); maestro.Pay(false, 200.2); }
static void Menu() { while (true) { string temp = ""; Console.WriteLine("Hvad er dit navn"); tempString = Console.ReadLine(); Console.WriteLine("Hvad er din alder"); tempInt = Convert.ToInt32(Console.ReadLine()); User user = new User(tempString, tempInt); if (user.Age < 15) { Console.WriteLine("Du kan få DebitCard eller MasterCard"); Console.WriteLine("Skriv D for Debit M for master"); temp = Console.ReadLine().ToLower(); switch (temp) { case "m": CreditCard M = new MasterCard(); M.CreateCard(user.Name); Console.WriteLine(M.ToString()); break; case "d": CreditCard DC = new DebitCard(); DC.CreateCard(user.Name); Console.WriteLine(DC.ToString()); break; } } if (user.Age > 18 || user.Age == 18) { Console.WriteLine("Du kan få Maestro, DebitCard, Mastercard eller Visa/Dankort"); Console.WriteLine("Skriv D for Debit MC for master VD for Visa M for Maestro"); temp = Console.ReadLine().ToLower(); switch (temp) { case "d": CreditCard DC = new DebitCard(); DC.CreateCard(user.Name); Console.WriteLine(DC.ToString()); break; case "mc": CreditCard MC = new MasterCard(); MC.CreateCard(user.Name); Console.WriteLine(MC.ToString()); break; case "vd": CreditCard VD = new VisaDankort(); VD.CreateCard(user.Name); Console.WriteLine(VD.ToString()); break; case "m": CreditCard M = new Maestro(); M.CreateCard(user.Name); Console.WriteLine(M.ToString()); break; default: break; } } if (user.Age == 15 || user.Age > 15) { Console.WriteLine("Du kan få Maestro, DebitCard, Mastercard, Visa Electron eller Visa/Dankort"); Console.WriteLine("Skriv D for Debit MC for master VD for VisaDankort VE for VisaElectron M for Maestro"); temp = Console.ReadLine().ToLower(); switch (temp) { case "d": CreditCard DC = new DebitCard(); DC.CreateCard(user.Name); Console.WriteLine(DC.ToString()); break; case "mc": CreditCard MC = new MasterCard(); MC.CreateCard(user.Name); Console.WriteLine(MC.ToString()); break; case "vd": CreditCard VD = new VisaDankort(); VD.CreateCard(user.Name); Console.WriteLine(VD.ToString()); break; case "m": CreditCard M = new Maestro(); M.CreateCard(user.Name); Console.WriteLine(M.ToString()); break; case "ve": CreditCard VE = new VisaElectron(); VE.CreateCard(user.Name); Console.WriteLine(VE.ToString()); break; default: break; } } } }
static void Main(string[] args) { //Start of menu Console.WriteLine("Welcome to this fancy bank"); Console.Write("Press Enter:"); Console.ReadLine(); //Ask for a name for the card Console.WriteLine("What is your name:"); string name = Console.ReadLine(); //instances Card withdrawalCard = new WithdrawalCard(name); Account account = new Account(name); //START of GUI //user input to navigate the menu int userInput; string age; int userAge; do { //Menu after your name is inputted Console.Clear(); Console.WriteLine("Press (1) to make a Mastercard\n" + "Press (2) to make a VISA Dancard\n" + "Press (3) to make a Maestro card\n" + "Press (4) to make a VISA Electron card\n" + "Press (5) to exit"); string input = Console.ReadLine(); userInput = int.Parse(input); switch (userInput) { //If Mastercard is chosen case 1: Card mastercard = new Mastercard(name); Console.Clear(); Console.WriteLine("Welcome " + name + "\nHere is your new card:\n"); Console.WriteLine("------------------------"); Console.WriteLine(mastercard.GetType().Name); Console.WriteLine("Belongs to: " + name); Console.WriteLine("Card number: " + mastercard.CardNumber); Console.WriteLine("Expiration date: " + mastercard.ExpireDate); Console.WriteLine("Account number: " + account.AccountNumber); Console.WriteLine("------------------------\n"); Console.Write("Press enter to continue: "); Console.ReadLine(); Console.Clear(); break; //If VISA Dancard is chosen case 2: Card visaDankort = new VISADankort(name); Console.Clear(); Console.WriteLine("How old are you?"); age = Console.ReadLine(); userAge = int.Parse(age); if (visaDankort.MinAge <= userAge) { Console.Clear(); Console.WriteLine("Welcome " + name + "\nHere is your new card:\n"); Console.WriteLine("------------------------"); Console.WriteLine(visaDankort.GetType().Name); Console.WriteLine("Belongs to: " + name); Console.WriteLine("Card number: " + visaDankort.CardNumber); Console.WriteLine("Expiration date: " + visaDankort.ExpireDate); Console.WriteLine("Account number: " + account.AccountNumber); Console.WriteLine("------------------------\n"); Console.Write("Press enter to continue: "); Console.ReadLine(); Console.Clear(); } else { Console.WriteLine($"Sorry, we cannot make a {visaDankort.GetType().Name} card because you are too young.\n" + $"Would you like to get a {withdrawalCard.GetType().Name} instead? ( yes / no )"); string withdrawCard = Console.ReadLine(); if (withdrawCard == "yes") { Console.Clear(); Console.WriteLine("Here is your new card:" + name + "\n"); Console.WriteLine("------------------------"); Console.WriteLine(withdrawalCard.GetType().Name); Console.WriteLine("Belongs to: " + name); Console.WriteLine("Card number: " + withdrawalCard.CardNumber); Console.WriteLine("Expiration date: " + withdrawalCard.ExpireDate); Console.WriteLine("Account number: " + account.AccountNumber); Console.WriteLine("------------------------\n"); Console.Write("Press enter to continue: "); Console.ReadLine(); } else if (withdrawCard == "no") { Console.Clear(); Console.WriteLine("Have a nice day\n"); Console.Write("Press enter to continue: "); Console.ReadLine(); } else { Console.Clear(); Console.WriteLine("There seemed to have been a wrong input\n"); Console.Write("Press enter to continue: "); Console.ReadLine(); } } break; //If Maestro card is chosen case 3: Card maestro = new Maestro(name); Console.Clear(); Console.WriteLine("How old are you?"); age = Console.ReadLine(); userAge = int.Parse(age); if (maestro.MinAge <= userAge) { Console.Clear(); Console.WriteLine("Welcome " + name + "\nHere is your new card:\n"); Console.WriteLine("------------------------"); Console.WriteLine(maestro.GetType().Name); Console.WriteLine("Belongs to: " + name); Console.WriteLine("Card number: " + maestro.CardNumber); Console.WriteLine("Expiration date: " + maestro.ExpireDate); Console.WriteLine("Account number: " + account.AccountNumber); Console.WriteLine("------------------------\n"); Console.Write("Press enter to continue: "); Console.ReadLine(); } else { Console.WriteLine($"Sorry, we cannot make a {maestro.GetType().Name} card because you are too young.\n" + $"Would you like to get a {withdrawalCard.GetType().Name} instead? ( yes / no )"); string withdrawCard = Console.ReadLine(); if (withdrawCard == "yes") { Console.Clear(); Console.WriteLine("Here is your new card:" + name + "\n"); Console.WriteLine("------------------------"); Console.WriteLine(withdrawalCard.GetType().Name); Console.WriteLine("Belongs to: " + name); Console.WriteLine("Card number: " + withdrawalCard.CardNumber); Console.WriteLine("Expiration date: " + withdrawalCard.ExpireDate); Console.WriteLine("Account number: " + account.AccountNumber); Console.WriteLine("------------------------\n"); Console.Write("Press enter to continue: "); Console.ReadLine(); } else if (withdrawCard == "no") { Console.Clear(); Console.WriteLine("Have a nice day\n"); Console.Write("Press enter to continue: "); Console.ReadLine(); } else { Console.Clear(); Console.WriteLine("There seemed to have been a wrong input\n"); Console.Write("Press enter to continue: "); Console.ReadLine(); } } break; //If VISA Electron is chosen case 4: Card visaElectron = new VISAElectron(name); Console.Clear(); Console.WriteLine("How old are you?"); age = Console.ReadLine(); userAge = int.Parse(age); if (visaElectron.MinAge <= userAge) { Console.Clear(); Console.WriteLine("Welcome " + name + "\nHere is your new card:\n"); Console.WriteLine("------------------------"); Console.WriteLine(visaElectron.GetType().Name); Console.WriteLine("Belongs to: " + name); Console.WriteLine("Card number: " + visaElectron.CardNumber); Console.WriteLine("Expiration date: " + visaElectron.ExpireDate); Console.WriteLine("Account number: " + account.AccountNumber); Console.WriteLine("------------------------\n"); Console.Write("Press enter to continue: "); Console.ReadLine(); } else { Console.WriteLine($"Sorry, we cannot make a {visaElectron.GetType().Name} card because you are too young.\n" + $"Would you like to get a {withdrawalCard.GetType().Name} instead? ( yes / no )"); string withdrawCard = Console.ReadLine(); if (withdrawCard == "yes") { Console.Clear(); Console.WriteLine("Here is your new card:" + name + "\n"); Console.WriteLine("------------------------"); Console.WriteLine(withdrawalCard.GetType().Name); Console.WriteLine("Belongs to: " + name); Console.WriteLine("Card number: " + withdrawalCard.CardNumber); Console.WriteLine("Expiration date: " + withdrawalCard.ExpireDate); Console.WriteLine("Account number: " + account.AccountNumber); Console.WriteLine("------------------------\n"); Console.Write("Press enter to continue: "); Console.ReadLine(); } else if (withdrawCard == "no") { Console.Clear(); Console.WriteLine("Have a nice day\n"); Console.Write("Press enter to continue: "); Console.ReadLine(); } else { Console.Clear(); Console.WriteLine("There seemed to have been a wrong input\n"); Console.Write("Press enter to continue: "); Console.ReadLine(); } } break; default: break; } //If the number 5 is pressed, the program closes } while (userInput != 5); }