static void Main(string[] args) { CardUser user = new CardUser("Nicky Hansen", 18); BankAccount[] bankAccounts = new BankAccount[5]; for (int i = 0; i < 5; i++) { bankAccounts[i] = new BankAccount(user); } DebitCard debitCard = new DebitCard(bankAccounts[0]); MaestroCard maestroCard = new MaestroCard(bankAccounts[1], DateTime.Now + TimeSpan.FromDays(365 * 5)); VisaElectron visaElectron = new VisaElectron(bankAccounts[2], DateTime.Now + TimeSpan.FromDays(365 * 5)); VisaDankort visaDankort = new VisaDankort(bankAccounts[3], DateTime.Now + TimeSpan.FromDays(365 * 5)); MasterCard masterCard = new MasterCard(bankAccounts[4], DateTime.Now + TimeSpan.FromDays(365 * 5)); debitCard.Deposit(16000); maestroCard.Deposit(16000); visaElectron.Deposit(11000); visaDankort.Deposit(10000); masterCard.Deposit(10000); // DebitCard / MaestroCard Test. Console.WriteLine($"Trying to withdraw: 15000 from debitCard got: {debitCard.Withdraw(15000)}"); Console.WriteLine($"Trying to withdraw: 15000 from maestroCard got: {maestroCard.Withdraw(15000)}"); // VisaElectron Test. Console.WriteLine($"Trying to withdraw: 10000 from visaElectron got: {visaElectron.Withdraw(10000)}"); Console.WriteLine($"Trying to withdraw: 1 from visaElectron got: {visaElectron.Withdraw(1)}"); // VisaDankort Test. Console.WriteLine($"Trying to withdraw: 25000 from visaDankort got: {visaDankort.Withdraw(25000)}"); Console.WriteLine($"Trying to withdraw: 1 from visaDankort got: {visaDankort.Withdraw(1)}"); // MasterCard Test. for (int i = 0; i < 7; i++) { Console.WriteLine($"Trying to withdraw: 5000 from masterCard got: {masterCard.Withdraw(5000)}"); Console.WriteLine("MasterCard Reset Daily Limit"); masterCard.ResetDailyUse(); } Console.WriteLine("-------------------------------------------------------------------"); Console.WriteLine(); Console.WriteLine(debitCard); Console.WriteLine(maestroCard); Console.WriteLine(visaElectron); Console.WriteLine(visaDankort); Console.WriteLine(masterCard); Console.ReadLine(); Console.ReadLine(); }
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 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; } } } }