Exemplo n.º 1
0
        public void TestPaymethodwithnegativevalue()
        {
            Bankaccount bankaccount = new Bankaccount("coen", "1234", 5.45m);

            bankaccount.Pay(-1.00m);

            Assert.AreEqual(5.45m, bankaccount.Balance);
        }
Exemplo n.º 2
0
        public void TestPaymethod()
        {
            Bankaccount bankaccount = new Bankaccount("coen", "1234", 5.45m);

            bankaccount.Pay(3.45m);

            Assert.AreEqual(2.0m, bankaccount.Balance);
        }
Exemplo n.º 3
0
        public void Testmakingbankaccountwiththreevalues()
        {
            Bankaccount bankaccount = new Bankaccount("coen", "1234", 5.45m);

            Assert.AreEqual("coen", bankaccount.AccountNumber);
            Assert.AreEqual(1234, bankaccount.Pincode);
            Assert.AreEqual(5.45m, bankaccount.Balance);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Create a owner.
        /// </summary>
        /// <param name="name">Name of the owner.</param>
        /// <param name="bankaccount">Bankaccountnumber.</param>
        /// <param name="authenticationCode">authenticationCode of the owner.</param>
        public  Owner (string name, Bankaccount bankaccount, string pinCode)
        {
            Name               = name;
            Bankaccount        = bankaccount;
            PinCode = pinCode;

            OwnedCars = new List<Car>();
        }
Exemplo n.º 5
0
 public bool ChangeBankAccount(Bankaccount bankAccount)
 {
     if(bankAccount != null)
     {
         Bankaccount = bankAccount;
         return true;
     }
     return false;
 }
Exemplo n.º 6
0
        private void UpdateFromTextDatabase()
        {
            List<string> listCars = new List<string>();
            List<string> listBankAccounts = new List<string>();
            List<string> listOwners = new List<string>();

            getTextFromFile(listCars, "carsdatabase.txt");
            getTextFromFile(listBankAccounts, "bankaccountdatabase.txt");
            getTextFromFile(listOwners, "ownerdatabase.txt");

            foreach(string ownerString in listOwners)
            {
                string[] dataOwner = ownerString.Split(',');
                Bankaccount ownerBankAccount = getBankaccount(listBankAccounts, dataOwner[1]);

                if (ownerBankAccount != null)
                {
                    Owners.Add(new Owner(dataOwner[0], ownerBankAccount, dataOwner[2]));
                }
                else
                {
                    newAccountNumber++;
                    newAuthenticationNumber++;
                    if (newAccountNumber > 9999)
                    {
                        newAuthenticationNumber = 1;
                    }
                    string newAccountNumberString = newAccountNumber.ToString();
                    string newAuthenticationNumberString = newAuthenticationNumber.ToString();
                    while (newAuthenticationNumberString.Length < 3)
                    {
                        newAuthenticationNumberString = "0" + newAuthenticationNumberString;
                    }
                    Bankaccount bankaccount = new Bankaccount(newAccountNumberString, newAuthenticationNumberString, 0);
                    Owners.Add(new Owner(dataOwner[0], bankaccount, dataOwner[2]));
                }
            }

            foreach (string carString in listCars)
            {
                string[] data = carString.Split(',');
                TypeOfFuel fueltype = TypeOfFuel.Unknown;
                switch (data[1])
                {
                    case "Petrol":
                        fueltype = TypeOfFuel.Petrol;
                        break;
                    case "Diesel":
                        fueltype = TypeOfFuel.Diesel;
                        break;
                    case "LPG":
                        fueltype = TypeOfFuel.LPG;
                        break;
                }
                foreach (Owner owner in Owners)
                {
                    if (owner.Name == data[4])
                    {
                        Car car = new Car(data[0], fueltype, data[2], Convert.ToDouble(data[3]), owner);
                        AllCars.Add(car);
                        owner.OwnedCars.Add(car);
                        break;
                    }
                }
            }

        }