Exemplo n.º 1
0
        public async Task <ActionResult <FamilyCar> > PostFamilyCar(FamilyCar familyCar)
        {
            _context.FamilyCar.Add(familyCar);
            await _context.SaveChangesAsync();

            return(familyCar);
        }
        public void accerlating_car_should_return_correct_speed()
        {
            var familyCar = new FamilyCar();

            familyCar.Accelerate().Should().Be(1);
            familyCar.Accelerate().Should().Be(2);
        }
Exemplo n.º 3
0
        private global::System.Collections.Generic.IReadOnlyList <global::Demo.IVehicle> ParseGetVehiclesVehicles(
            JsonElement parent,
            string field)
        {
            JsonElement obj = parent.GetProperty(field);

            int objLength = obj.GetArrayLength();
            var list      = new global::Demo.IVehicle[objLength];

            for (int objIndex = 0; objIndex < objLength; objIndex++)
            {
                JsonElement element = obj[objIndex];
                string      type    = element.GetProperty(TypeName).GetString();

                switch (type)
                {
                case "SportsCar":
                    list[objIndex] = new SportsCar
                                     (
                                     );
                    break;

                case "FamilyCar":
                    list[objIndex] = new FamilyCar
                                     (
                                     );
                    break;

                default:
                    throw new UnknownSchemaTypeException(type);
                }
            }

            return(list);
        }
Exemplo n.º 4
0
        static void Main(string[] args)
        {
            // Use the car without any service injection
            var car = new FamilyCar();

            car.Move();
            car.Stop();

            var host = car as IActivatorHost;

            if (host == null)
            {
                return;
            }

            // Configure the StructureMap container
            var registry = new Registry();

            registry.ForRequestedType <Engine>().
            TheDefaultIsConcreteType <RaceCarEngine>();

            var container = new Container(registry);
            var locator   = new StructureMapServiceLocator(container);
            var activator = new ContainerTypeActivator(locator);


            host.Activator = activator;

            // Use the car after the new operator call has been
            // replaced with the call to the SM container
            car.Move();
            car.Stop();

            return;
        }
        public void starting_car_twice_should_throw_exception()
        {
            var    familyCar   = new FamilyCar();
            Action startAction = () => familyCar.Start();

            startAction.ShouldNotThrow <EngineAlreadyStartedException>();
            startAction.ShouldThrow <EngineAlreadyStartedException>();
        }
Exemplo n.º 6
0
        static void Main(string[] args)
        {
            var normalCar1 = new NormalCar();
            var normalCar2 = new NormalCar();

            var sportsCar = new SportsCar();
            var familyCar = new FamilyCar();
        }
Exemplo n.º 7
0
        public async Task <ActionResult <FamilyCar> > PutFamilyCar(long id, FamilyCar familyCar)
        {
            if (id != familyCar.FamilyCarId)
            {
                return(BadRequest());
            }

            return(await _repository.PutFamilyCar(id, familyCar));
        }
Exemplo n.º 8
0
        static void Main(string[] args)
        {
            //var kona = new Car();
            //kona.IsLuxury = true;
            //kona.Price = 10000;

            //kona.DisplayInfo();

            //var santafe = new Car("Hyundai SantaFE", 3000);

            //santafe.DisplayInfo();

            var car = new FamilyCar("nhat");

            car.DisplayInfo();

            Utils.ShowNewLine();

            var consCar = new ConstructCar("construct car");

            consCar.DisplayInfo();

            Utils.ShowNewLine("~");

            Car fCar = new FamilyCar();

            fCar.Run();

            Utils.ShowNewLine();

            Car cCar = new ConstructCar();

            cCar.Run();

            Utils.ShowNewLine("~");

            Animal an = new Animal();

            an.SayHello();

            Animal dog = new Dog("Yellow");

            dog.SayHello();

            Utils.ShowNewLine("~");

            var faCar = new FamilyCar();

            faCar.DisplayCarInfo();

            Console.ReadLine();

            var trCar = new TransportsCar();

            trCar.DisplayCarInfo();
        }
Exemplo n.º 9
0
        public static void Main()
        {
            FamilyCar familyCar = new FamilyCar(100, 10);

            // System.Console.WriteLine(familyCar.FuelConsumption);

            SportCar sportCar = new SportCar(100, 20);

            System.Console.WriteLine(sportCar.FuelConsumption);
        }
Exemplo n.º 10
0
        public static void Main(string[] args)
        {
            FamilyCar newCar = new FamilyCar(100, 100);

            newCar.Drive(25);

            SportCar sportCar = new SportCar(100, 100);

            sportCar.Drive(10);
        }
Exemplo n.º 11
0
        public async Task <ActionResult <FamilyCar> > PutFamilyCar(long id, FamilyCar familyCar)
        {
            if (id != familyCar.FamilyCarId)
            {
                return(null);
            }
            _context.Entry(familyCar).State = EntityState.Modified;
            await _context.SaveChangesAsync();

            return(familyCar);
        }
Exemplo n.º 12
0
        public static void Main(string[] args)
        {
            RaceMotorcycle motor = new RaceMotorcycle(234, 2887);

            motor.Drive(100);
            System.Console.WriteLine(motor.Fuel);
            FamilyCar familyCar = new FamilyCar(75, 32333);

            System.Console.WriteLine($"before drive : {familyCar.Fuel}");
            familyCar.Drive(200);
            System.Console.WriteLine($"after drive {familyCar.Fuel}");
        }
Exemplo n.º 13
0
        public void Run()
        {
            FamilyCar       familyCar       = new FamilyCar(100, 25.60);
            SportCar        sportCar        = new SportCar(45, 190);
            CrossMotorcycle crossMotorcycle = new CrossMotorcycle(200, 56.30);
            RaceMotorcycle  raceMotorcycle  = new RaceMotorcycle(250, 90.99);

            familyCar.Drive(5);
            sportCar.Drive(10);
            crossMotorcycle.Drive(25);
            raceMotorcycle.Drive(2);

            Console.WriteLine(familyCar);
            Console.WriteLine(sportCar);
            Console.WriteLine(crossMotorcycle);
            Console.WriteLine(raceMotorcycle);
        }
Exemplo n.º 14
0
 private void btAddCar_Click(object sender, EventArgs e)
 {
     if (isSportsCar)
     {
         Car sportscar = new SportsCar(tbBrand.Text, tbModel.Text, DateTime.Parse(mtbInUseDate.Text), mtbLicensePlate.Text, int.Parse(nudHorsePower.Value.ToString()), int.Parse(nudSpeedSettings.Value.ToString()));
         Cars.Add(sportscar);
     }
     else
     {
         Car familycar = new FamilyCar(tbBrand.Text, tbModel.Text, DateTime.Parse(mtbInUseDate.Text), mtbLicensePlate.Text, int.Parse(nudHorsePower.Value.ToString()), int.Parse(nudSpeedSettings.Value.ToString()));
         Cars.Add(familycar);
     }
     lbCars.Items.Clear();
     foreach (Car car in Cars)
     {
         lbCars.Items.Add(car);
     }
 }
Exemplo n.º 15
0
 public Driver1(CarFactory factory)
 {
     familycar = factory.CreatFamilyCar();
     sportscar = factory.CreatSportsCar();
 }
Exemplo n.º 16
0
        public static void Main(string[] args)
        {
            FamilyCar car = new FamilyCar(100, 40);

            car.Drive(5);
        }
Exemplo n.º 17
0
 public Rent()
 {
     familyCar = new FamilyCar();
     sportCar = new SportCar();
     StartDate = DateTime.Today;
 }
Exemplo n.º 18
0
    public bool ChooseCar(string carType)
    {
        if(carType == null)
        {
            throw new ArgumentNullException();
        }

        if(carType == "familycar")
        {
            SelectedCar = new FamilyCar();
            return true;
            // return familyCar;
        }
        else if(carType == "sportcar")
        {
            SelectedCar = new SportCar();
            return true;
            //return sportCar;
        }
        else
        {
            throw new ArgumentException(String.Format("{0} är ingen giltig biltyp", carType));
        }
    }
Exemplo n.º 19
0
    public double CalcTotal(double milage, double days, string c)
    {
        var total = 0.0;
        try
        {
            if (milage > 0 && days > 0)
                if (c == "SportCar")
                {
                    var car = new SportCar();
                    total = car.DailyCost * days + car.MilageCost * milage + car.ExtraInsurance + penaltyCost + discount;
                    return total;
                }
                else if (c == "FamilyCar")
                {
                    var car = new FamilyCar();
                    total = car.DailyCost * days + car.MilageCost * milage + car.ExtraInsurance + penaltyCost + discount;
                    return total;
                }
                else
                {
                    MessageBox.Show("Du har ej angivit godkänd typ av bil");
                }
            //else
            //    MessageBox.Show("0 i värde är ej tillåtet");

        }
        catch (FormatException)
        {

            MessageBox.Show("You have entered non-numeric characters");

        }
        return total;
    }
Exemplo n.º 20
0
 public void Setup()
 {
     sportcar = new SportCar();
     familycar = new FamilyCar();
 }
Exemplo n.º 21
0
 public Driver(CarFactory Car)
 {
     sportsCar = Car.CreateSortsCar();
     familyCar = Car.CreateFamilyCar();
 }
Exemplo n.º 22
0
 public Driver(CarFactory factory)
 {
     sport  = factory.CreateSportCar();
     family = factory.CreateFamilyCar();
 }
Exemplo n.º 23
0
 public Driver(CarFactory carFactory)
 {
     _sportsCar = carFactory.CreateSportsCar();
     _familyCar = carFactory.CreateFamilyCar();
 }
Exemplo n.º 24
0
 public async Task <ActionResult <FamilyCar> > PostFamilyCar(FamilyCar familyCar)
 {
     return(await _repository.PostFamilyCar(familyCar));
 }
Exemplo n.º 25
0
        static void Main(string[] args)
        {
            #region "Exercise 4.1"

            Console.WriteLine("----- Exercise 4.1 -----");
            Console.WriteLine();

            #region "Initializing objects"

            Console.WriteLine("----- Class pet -----");
            Console.WriteLine();

            Console.WriteLine("----- Initialize pets -----");
            Console.WriteLine();

            const int AMOUNT1 = 10;

            List <Pet> pets = new List <Pet>();

            for (int i = 0; i < AMOUNT1; i++)
            {
                pets.Add(Cat.MakeRandomPet());
                pets.Add(Dog.MakeRandomPet());
            }

            foreach (Pet pet in pets)
            {
                Console.WriteLine(pet);
            }

            #endregion "Initializing objects"

            #region "Test methods"

            Console.WriteLine("----- Testing of pet methods -----");
            Console.WriteLine();

            Console.WriteLine("----- Make noise -----");
            Console.WriteLine();

            foreach (Pet pet in pets)
            {
                Console.WriteLine(pet.MakeNoise());
                Console.WriteLine();
            }

            #endregion "Test methods"

            #endregion "Exercise 4.1"

            #region "Exercise 4.2"

            Console.WriteLine("----- Exercise 4.2 -----");
            Console.WriteLine();

            #region "Initializing objects"

            Console.WriteLine("----- Class car -----");
            Console.WriteLine();

            Console.WriteLine("----- Initialize sportscars -----");
            Console.WriteLine();

            const int AMOUNT2 = 10;

            List <Car> cars = new List <Car>();

            for (int i = 0; i < AMOUNT2; i++)
            {
                cars.Add(SportsCar.MakeRandomCar());
                cars.Add(FamilyCar.MakeRandomCar());
            }

            foreach (Car car in cars)
            {
                Console.WriteLine(car);
            }

            #endregion "Initializing objects"

            #region "Test methods"

            Console.WriteLine("----- Testing of car methods -----");
            Console.WriteLine();

            Console.WriteLine("----- Testing fuel consumption -----");
            Console.WriteLine();

            foreach (Car car in cars)
            {
                Console.WriteLine(car.CalculateFuelConsumption());
                Console.WriteLine();
            }

            Console.WriteLine("----- Testing kilometer count -----");
            Console.WriteLine();

            foreach (Car car in cars)
            {
                Console.WriteLine(car.CalculateKilometers());
                Console.WriteLine();
            }

            #endregion "Test methods"

            #endregion "Oef 4.2"

            #region "Exercise 4.3"

            Console.WriteLine("----- Exercise 4.3 -----");
            Console.WriteLine();

            #region "Initalizing objects"

            Console.WriteLine("----- Class Product -----");
            Console.WriteLine();

            Console.WriteLine("----- Initializing products -----");
            Console.WriteLine();

            const int AMOUNT3 = 10;

            List <Product> products = new List <Product>();

            for (int i = 0; i < AMOUNT3; i++)
            {
                products.Add(FoodProduct.MakeRandomProduct());
                products.Add(NonFoodProduct.MakeRandomProduct());
            }

            foreach (Product product in products)
            {
                Console.WriteLine(product);
            }

            Console.WriteLine("----- Class Store -----");
            Console.WriteLine();

            Console.WriteLine("----- Initializing store -----");
            Console.WriteLine();

            Store store = new Store();

            #endregion "Initalizing objects"

            #region "Testing methods"

            Console.WriteLine("----- Testing of store methods -----");
            Console.WriteLine();

            Console.WriteLine("----- Adding products -----");
            Console.WriteLine();

            foreach (Product product in products)
            {
                store.AddProduct(product);
            }

            Console.WriteLine(store);

            Console.WriteLine("----- Finding a product -----");
            Console.WriteLine();

            //List to contain the names of all the products
            List <string> names = new List <string>();

            foreach (Product product in products)
            {
                names.Add(product.GetProductName());
            }

            Product product1 = store.FindProduct(names[0]);
            Console.WriteLine($"Product 1: \n{product1}");

            Console.WriteLine("----- Removing the product -----");
            Console.WriteLine();

            store.RemoveProduct(product1);
            Console.WriteLine(store);

            #endregion "Testing methods"

            #endregion "Exercise 4.3"

            #region "Exercise 4.4"

            Console.WriteLine("----- Exercise 4.4 -----");
            Console.WriteLine();

            #region "Initalizing objects"

            Console.WriteLine("----- Class Person -----");
            Console.WriteLine();

            Console.WriteLine("----- Initializing people -----");
            Console.WriteLine();

            const int AMOUNT4 = 10;

            List <Attendee> attendees = new List <Attendee>();
            List <Artist>   artists   = new List <Artist>();

            for (int i = 0; i < AMOUNT4; i++)
            {
                attendees.Add(Attendee.MakeRandomPerson());
                artists.Add(Artist.MakeRandomPerson());
            }

            foreach (Person artist in artists)
            {
                Console.WriteLine(artist);
                Console.WriteLine();
            }

            foreach (Person attendee in attendees)
            {
                Console.WriteLine(attendee);
                Console.WriteLine();
            }

            Console.WriteLine("----- Class Festival -----");
            Console.WriteLine();

            Console.WriteLine("----- Initializing festival -----");
            Console.WriteLine();

            Festival festival = new Festival();

            #endregion "Initalizing objects"

            #region "Testing methods"

            Console.WriteLine("----- Testing of festival methods -----");
            Console.WriteLine();

            Console.WriteLine("----- Adding artists -----");
            Console.WriteLine();

            foreach (Artist artist in artists)
            {
                festival.AddArtist(artist);
            }

            Console.WriteLine(festival);

            Console.WriteLine("----- Finding an artist -----");
            Console.WriteLine();

            //List to contain the names of all the products

            Artist artist1 = festival.FindArtist(artists[0].FirstName, artists[0].LastName);
            Console.WriteLine($"Artist 1: \n{artist1}");

            Console.WriteLine("----- Removing the artist -----");
            Console.WriteLine();

            festival.RemoveArtist(artist1);
            Console.WriteLine(festival);

            Console.WriteLine("----- Adding attendees -----");
            Console.WriteLine();

            foreach (Attendee attendee in attendees)
            {
                festival.AddAttendee(attendee);
            }

            Console.WriteLine(festival);

            Console.WriteLine("----- Calculating income prices -----");
            Console.WriteLine();

            decimal incomePrice = 50;
            Console.WriteLine($"Standard price: {incomePrice}");

            foreach (Attendee attendee in attendees)
            {
                Console.WriteLine("-----");
                Console.WriteLine(attendee);
                Console.WriteLine($"Income price: {festival.CalculateIncomePrice(incomePrice, attendee)}");
                Console.WriteLine("-----");
                Console.WriteLine();
            }

            Console.WriteLine("----- Finding an attendee -----");
            Console.WriteLine();

            //List to contain the names of all the products

            Attendee attendee1 = festival.FindAttendee(attendees[0].FirstName, attendees[0].LastName);
            Console.WriteLine($"Attendee 1: \n{attendee1}");

            Console.WriteLine("----- Removing the attendee -----");
            Console.WriteLine();

            festival.RemoveAttendee(attendee1);
            Console.WriteLine(festival);

            #endregion "Testing methods"

            #endregion "Exercise 4.4"

            #region "Exercise 4.5"

            Console.WriteLine("----- Exercise 4.5 -----");
            Console.WriteLine();

            #region "Initializing objects"

            Console.WriteLine("----- Class Customer -----");
            Console.WriteLine();

            Console.WriteLine("----- Initializing customers -----");
            Console.WriteLine();

            const int AMOUNT5 = 10;

            List <Customer> customers = new List <Customer>();

            //Creating the customers
            for (int i = 0; i < AMOUNT5; i++)
            {
                customers.Add(Customer.MakeRandomCustomer());
            }

            const int AMOUNTOFACCOUNTS = 4;
            int       randomNumber     = generator.Next(0, 2);
            //adding bankaccounts to the customers
            foreach (Customer customer in customers)
            {
                for (int j = 0; j < AMOUNTOFACCOUNTS; j++)
                {
                    //to randomize what account is added
                    //adds a savingsaccount
                    if (randomNumber <= 0)
                    {
                        customer.AddBankAccount(SavingsAccount.MakeRandomAccount());
                    }
                    //adds an investementaccount
                    else if (randomNumber > 0)
                    {
                        customer.AddBankAccount(InvestmentAccount.MakeRandomAccount());
                    }
                }
            }

            const int AMOUNTOFTRANSACTIONS = 6;

            foreach (Customer customer in customers)
            {
                foreach (BankAccount bankAccount in customer.BankAccounts)
                {
                    int      randomYear  = generator.Next(DateTime.Today.Year - 80, DateTime.Today.Year + 1);
                    int      randomMonth = generator.Next(1, 13);
                    int      randomDay   = generator.Next(1, DateTime.DaysInMonth(randomYear, randomMonth) + 1);
                    DateTime randomDate  = new DateTime(randomYear, randomMonth, randomDay);
                    decimal  randomValue = (decimal)generator.Next(100, 100000) / 100;
                    for (int k = 0; k < AMOUNTOFTRANSACTIONS; k++)
                    {
                        if (bankAccount.GetType() == typeof(SavingsAccount))
                        {
                            bankAccount.DepositMoney(randomValue, randomDate);
                        }
                        else if (bankAccount.GetType() == typeof(InvestmentAccount))
                        {
                            if (randomNumber <= 0)
                            {
                                bankAccount.DepositMoney(randomValue, randomDate);
                            }
                            else if (randomNumber > 0)
                            {
                                TimeSpan randomPeriod = new TimeSpan(generator.Next(30, 1826), 0, 0, 0);
                                ((InvestmentAccount)bankAccount).InvestMoney(randomValue, randomPeriod, randomDate);
                            }
                        }
                    }
                }
            }

            foreach (Customer customer in customers)
            {
                Console.WriteLine(customer);
            }

            Console.WriteLine("----- Class Bank -----");
            Console.WriteLine();

            Console.WriteLine("----- Initializing bank -----");
            Console.WriteLine();

            Bank bank = new Bank("A bank", Address.MakeRandomAddress());
            Console.WriteLine(bank);

            #endregion "Initializing objects"

            #region "Testing methods"

            Console.WriteLine("----- Testing methods -----");
            Console.WriteLine();

            Console.WriteLine("----- Adding customers -----");
            Console.WriteLine();

            foreach (Customer customer in customers)
            {
                bank.AddCustomer(customer);
            }
            Console.WriteLine(bank);

            Console.WriteLine("----- Listing customers -----");
            Console.WriteLine();

            Console.WriteLine(bank.ListCustomers());

            Console.WriteLine("----- Finding a customer -----");
            Console.WriteLine();

            Customer customer1 = bank.FindCustomer(1);
            Console.WriteLine(customer1);

            Console.WriteLine("----- Removing a customer -----");
            Console.WriteLine();

            bank.RemoveCustomer(customer1);
            Console.WriteLine(bank);

            Console.WriteLine("----- Adding a customer -----");
            Console.WriteLine();

            bank.AddCustomer(customer1);
            Console.WriteLine(bank);

            Console.WriteLine("----- Listing all bankaccounts of customer 1-----");
            Console.WriteLine();

            Console.WriteLine(customer1.ListBankAccounts());
            Console.WriteLine();

            Console.WriteLine("----- Finding a bankaccount -----");
            Console.WriteLine();

            BankAccount bankAccount1 = customer1.FindBankAccount(1);
            Console.WriteLine(bankAccount1);

            Console.WriteLine("----- Removing a bankaccount -----");
            Console.WriteLine();

            customer1.RemoveBankAccount(bankAccount1);
            Console.WriteLine(customer1);

            Console.WriteLine("----- Adding a bankaccount -----");
            Console.WriteLine();

            customer1.AddBankAccount(bankAccount1);
            Console.WriteLine(customer1);

            Console.WriteLine("----- Listing all transactions of bankaccount 1 -----");
            Console.WriteLine();

            Console.WriteLine(bankAccount1.ListTransactions());

            Console.WriteLine("----- Finding a transaction -----");
            Console.WriteLine();

            Transaction transaction1 = bankAccount1.FindTransaction(1);
            Console.WriteLine(transaction1);

            Console.WriteLine("----- Removing a transaction -----");
            Console.WriteLine();

            bankAccount1.RemoveTransaction(transaction1);
            Console.WriteLine(bankAccount1);

            Console.WriteLine("----- Adding a transaction -----");
            Console.WriteLine();

            bankAccount1.AddTransaction(transaction1);
            Console.WriteLine(bankAccount1);

            Console.WriteLine("----- Making a savings account -----");
            Console.WriteLine();

            SavingsAccount savingsAccount = SavingsAccount.MakeRandomAccount();
            Console.WriteLine(savingsAccount);

            Console.WriteLine("----- Depositing money to the account -----");
            Console.WriteLine();

            int AMOUNTOFDEPOSITS1 = 10;

            for (int i = 0; i < AMOUNTOFDEPOSITS1; i++)
            {
                int      randomYear  = generator.Next(DateTime.Today.Year - 80, DateTime.Today.Year + 1);
                int      randomMonth = generator.Next(1, 13);
                int      randomDay   = generator.Next(1, DateTime.DaysInMonth(randomYear, randomMonth) + 1);
                DateTime randomDate  = new DateTime(randomYear, randomMonth, randomDay);
                decimal  randomValue = (decimal)generator.Next(100, 100000) / 100;
                savingsAccount.DepositMoney(randomValue, randomDate);
            }

            Console.WriteLine(savingsAccount.ListTransactions());
            Console.WriteLine();
            Console.WriteLine($"Account balance: \u20AC {savingsAccount.CalculateAccountBalance():N}");
            Console.WriteLine();

            Console.WriteLine("----- Withrawing money from account -----");
            Console.WriteLine();

            int AMOUNTOFWITHDRAWALS1 = 10;

            try
            {
                for (int i = 0; i < AMOUNTOFWITHDRAWALS1; i++)
                {
                    int      randomYear  = generator.Next(DateTime.Today.Year - 80, DateTime.Today.Year + 1);
                    int      randomMonth = generator.Next(1, 13);
                    int      randomDay   = generator.Next(1, DateTime.DaysInMonth(randomYear, randomMonth) + 1);
                    DateTime randomDate  = new DateTime(randomYear, randomMonth, randomDay);
                    decimal  randomValue = (decimal)generator.Next(10, 10000) / 100;
                    savingsAccount.WithdrawMoney(randomValue, randomDate);
                }
            }
            catch (Exception)
            {
                Console.WriteLine("Insufficient funds");
            }

            Console.WriteLine(savingsAccount.ListTransactions());
            Console.WriteLine();
            Console.WriteLine($"Account balance: \u20AC {savingsAccount.CalculateAccountBalance():N}");
            Console.WriteLine();

            Console.WriteLine("----- Making an investement account -----");
            Console.WriteLine();

            InvestmentAccount investmentAccount = InvestmentAccount.MakeRandomAccount();
            Console.WriteLine(investmentAccount);

            Console.WriteLine("----- Depositing money into the account -----");
            Console.WriteLine();

            int AMOUNTOFDEPOSITS2 = 5;

            for (int i = 0; i < AMOUNTOFDEPOSITS2; i++)
            {
                int      randomYear  = generator.Next(DateTime.Today.Year - 80, DateTime.Today.Year + 1);
                int      randomMonth = generator.Next(1, 13);
                int      randomDay   = generator.Next(1, DateTime.DaysInMonth(randomYear, randomMonth) + 1);
                DateTime randomDate  = new DateTime(randomYear, randomMonth, randomDay);
                decimal  randomValue = (decimal)generator.Next(100, 100000) / 100;
                investmentAccount.DepositMoney(randomValue, randomDate);
            }

            Console.WriteLine(investmentAccount.ListTransactions());
            Console.WriteLine();
            Console.WriteLine($"Account balance: \u20AC {investmentAccount.CalculateAccountBalance():N}");
            Console.WriteLine();


            Console.WriteLine("----- Investing money into the account -----");
            Console.WriteLine();

            int AMOUNTOFINVESTEMENTS = 5;

            for (int i = 0; i < AMOUNTOFINVESTEMENTS; i++)
            {
                int      randomYear   = generator.Next(DateTime.Today.Year - 80, DateTime.Today.Year + 1);
                int      randomMonth  = generator.Next(1, 13);
                int      randomDay    = generator.Next(1, DateTime.DaysInMonth(randomYear, randomMonth) + 1);
                DateTime randomDate   = new DateTime(randomYear, randomMonth, randomDay);
                decimal  randomValue  = (decimal)generator.Next(100, 100000) / 100;
                TimeSpan randomPeriod = new TimeSpan(generator.Next(30, 1826), 0, 0, 0);
                investmentAccount.InvestMoney(randomValue, randomPeriod, randomDate);
            }

            Console.WriteLine(investmentAccount.ListTransactions());
            Console.WriteLine();
            Console.WriteLine($"Account balance: \u20AC {investmentAccount.CalculateAccountBalance():N}");
            Console.WriteLine();


            #endregion "Testing methods"

            #endregion "Exercise 4.5"
        }
Exemplo n.º 26
0
        public void to_string_should_print_correct_value()
        {
            var familyCar = new FamilyCar();

            familyCar.ToString().Should().Be("FamilyCar");
        }
Exemplo n.º 27
0
        public static void Main(string[] args)
        {
            FamilyCar familyCar = new FamilyCar(150, 50);

            System.Console.WriteLine(familyCar);
        }