Exemplo n.º 1
0
        public static void Main(string[] args)
        {
            ourBank     = new Bank();
            ourBabyBank = new BabyBank();
            Acc1        = new CustomerAccount("Rob", 1000000);
            BabyAcc1    = new BabyAccount("David", 100, "Rob");
            Acc2        = new CustomerAccount("Jim", 50);

            Acc1.SaveAccountOn("Test.txt", Acc1);
            BabyAcc1.SaveAccountOn("TestB.txt", BabyAcc1);

            StoreTest(ourBank, Acc1);
            StoreTest(ourBabyBank, BabyAcc1);

            CustomerAccount loadedAcc     = Acc1.GenerateAccountFrom("Test.txt");
            CustomerAccount loadedBabyAcc = BabyAcc1.GenerateAccountFrom("TestB.txt");
            BabyAccount     loadedBabeAcc = (BabyAccount)loadedBabyAcc;

            FindTest(ourBank);

            Testing(BabyAcc1);
            Testing(Acc2);

            amount = 30;
            Transfer(Acc1, Acc2, amount, ourBank);

            DoEdit(Acc1);
            DoEdit(BabyAcc1);
            DoEdit(Acc2);

            Console.ReadLine();
        }
Exemplo n.º 2
0
        public override CustomerAccount GenerateAccountFrom(string filename)
        {
            BabyAccount result = null;

            using (StreamReader textIn = new StreamReader(filename))
            {
                try
                {
                    string nameText = textIn.ReadLine();

                    string  balanceText = textIn.ReadLine();
                    decimal balance     = decimal.Parse(balanceText);

                    string parent = textIn.ReadLine();

                    Console.WriteLine("Name: {0}", nameText);
                    Console.WriteLine("Balance: {0}", balance);
                    Console.WriteLine("Parent Name: {0}", parent);

                    result = new BabyAccount(nameText, balance, parent);

                    textIn.Close();
                    Console.WriteLine("File loaded correctly");
                }
                catch (ArgumentNullException ex)
                {
                    throw ex;
                }
                return(result);
            }
        }