コード例 #1
0
        public void ImperialMilesPerGallonAndLitersPerHundredKm()
        {
            double expected = 282.481;
            double actual   = FuelEconomy.MilesPerGallonImperialToLitersPerHundredKm(1);

            Assert.Equal(expected, actual);
        }
コード例 #2
0
        private void submitButton_Click(object sender, System.EventArgs e)
        {
            FuelEconomy milage = new FuelEconomy();

            milage.milesPerGallon = Convert.ToDecimal(milageTextBox.Text);
            Weight weight = new Weight();

            weight.kilograms = Convert.ToDecimal(weightTextBox.Text);
            Weight loadWeight = new Weight();

            if (loadCheckBox.Checked)
            {
                loadWeight.kilograms = Convert.ToDecimal(loadWeightTextBox.Text);
            }
            Volume maxFuel = new Volume();

            maxFuel.litres = Convert.ToDecimal(maxFuelTextBox.Text);

            LorryServices lorryServiceObj = new LorryServices();

            lorryServiceObj.Add(
                vehicleNameTextBox.Text,
                numberPlateTextBox.Text,
                milage,
                weight,
                loadCheckBox.Checked,
                loadWeight,
                maxFuel,
                Convert.ToInt32(maxPassengersTextBox.Text)
                );

            (Owner as LorryFormView).FillLorryList();
            Close();
        }
コード例 #3
0
        public void ImperialMilesPerGallonAndKilometersPerLiter()
        {
            double expected = 0.35398230088495575;
            double actual   = FuelEconomy.MilesPerGallonImperialToKilometersPerLiter(1);

            Assert.Equal(expected, actual);
        }
コード例 #4
0
        public void MilesPerGallonAndKilometersPerLitre()
        {
            double expected = 0.4251700680272109;
            double actual   = FuelEconomy.MilesPerGallonToKilometersPerLitre(1);

            Assert.Equal(expected, actual);
        }
コード例 #5
0
        public void MilesPerGallonAndLitresPerHundredkm()
        {
            double expected = 235.215;
            double actual   = FuelEconomy.MilesPerGallonToLitresPerHundredkm(1);

            Assert.Equal(expected, actual);
        }
コード例 #6
0
        public void MilesPerGallonAndMilesPerGallonImperial()
        {
            double expected = 1.201;
            double actual   = FuelEconomy.MilesPerGallonToMilesPerGallonImperial(1);

            Assert.Equal(expected, actual);
        }
コード例 #7
0
        private void submitButton_Click(object sender, System.EventArgs e)
        {
            FuelEconomy milage = new FuelEconomy();

            milage.milesPerGallon = Convert.ToDecimal(milageTextBox.Text);
            Weight weight = new Weight();

            weight.kilograms = Convert.ToDecimal(weightTextBox.Text);
            Weight loadWeight = new Weight();
            Volume maxFuel    = new Volume();

            maxFuel.litres = Convert.ToDecimal(maxFuelTextBox.Text);

            MotorbikeServices motorbikeServiceObj = new MotorbikeServices();

            motorbikeServiceObj.Add(
                vehicleNameTextBox.Text,
                numberPlateTextBox.Text,
                milage,
                weight,
                maxFuel,
                Convert.ToInt32(maxPassengersTextBox.Text),
                sideCarCheckBox.Checked
                );

            (Owner as MotorbikeFormView).FillMotorbikeList();
            Close();
        }
コード例 #8
0
        public void KilometersPerLiterAndLitersPerHunngredKm()
        {
            double expected = 100;
            double actual   = FuelEconomy.KilometersPerLiterToLitersPerHundredKm(1);

            Assert.Equal(expected, actual);
        }
コード例 #9
0
        private void submitButton_Click(object sender, EventArgs e)
        {
            FuelEconomy milage = new FuelEconomy();

            milage.milesPerGallon = Convert.ToDecimal(milageTextBox.Text);

            Weight weight = new Weight();

            weight.kilograms = Convert.ToDecimal(weightTextBox.Text);

            Volume fuel = new Volume();

            fuel.litres = Convert.ToDecimal(maxFuelTextBox.Text);

            Car.CarType carType = new Car.CarType();
            carType = Car.CarType.Unknown;

            switch (carTypeComboBox.Text)
            {
            case "Convertible":
                carType = Car.CarType.Convertible;
                break;

            case "Coupe":
                carType = Car.CarType.Coupe;
                break;

            case "Hatchback":
                carType = Car.CarType.Hatchback;
                break;

            case "Sedan":
                carType = Car.CarType.Sedan;
                break;

            case "SUV":
                carType = Car.CarType.SUV;
                break;
            }

            carServicesObj.Add(
                vehicleNameTextBox.Text,
                numberPlateTextBox.Text,
                carType,
                milage,
                weight,
                fuel,
                Convert.ToInt32(maxPassengersTextBox.Text)
                );

            (Owner as CarFormView).FillCarList();
            Close();
        }
コード例 #10
0
 public Car(string vehicleName, string numberPlate, CarType carType, FuelEconomy milage, Weight weight,
            Volume maximumFuel, int maximumPassengers)
 {
     this.vehicleName       = vehicleName;
     this.numberPlate       = numberPlate;
     this.carType           = carType;
     this.milage            = milage;
     this.weight            = weight;
     this.maximumFuel       = maximumFuel;
     currentFuel            = maximumFuel;
     this.maximumPassengers = maximumPassengers;
     passengers             = new List <Passenger>();
 }
コード例 #11
0
 public Motorbike(string vehicleName, string numberPlate, FuelEconomy milage, Weight weight,
                  Volume maximumFuel, int maximumPassengers, bool sideCar)
 {
     this.vehicleName       = vehicleName;
     this.numberPlate       = numberPlate;
     this.milage            = milage;
     this.weight            = weight;
     this.maximumFuel       = maximumFuel;
     currentFuel            = maximumFuel;
     this.maximumPassengers = maximumPassengers;
     this.sideCar           = sideCar;
     passengers             = new List <Passenger>();
 }
コード例 #12
0
 public Lorry(string vehicleName, string numberPlate, FuelEconomy milage, Weight weight, bool hasLoad,
              Weight loadWeight, Volume maximumFuel, int maximumPassengers)
 {
     this.vehicleName       = vehicleName;
     this.numberPlate       = numberPlate;
     this.milage            = milage;
     this.weight            = weight;
     this.hasLoad           = hasLoad;
     this.loadWeight        = loadWeight;
     this.maximumFuel       = maximumFuel;
     currentFuel            = maximumFuel;
     this.maximumPassengers = maximumPassengers;
     passengers             = new List <Passenger>();
 }
コード例 #13
0
        protected void submitBtn_Click(object sender, EventArgs e)
        {
            Car.CarType carTypeOfNewCar = Car.CarType.Unknown;
            switch (carTypeDdl.Text)
            {
            case "Unknown":
                carTypeOfNewCar = Car.CarType.Unknown;
                break;

            case "Hatchback":
                carTypeOfNewCar = Car.CarType.Hatchback;
                break;

            case "Sedan":
                carTypeOfNewCar = Car.CarType.Sedan;
                break;

            case "SUV":
                carTypeOfNewCar = Car.CarType.SUV;
                break;

            case "Coupe":
                carTypeOfNewCar = Car.CarType.Coupe;
                break;

            case "Convertible":
                carTypeOfNewCar = Car.CarType.Convertible;
                break;
            }

            FuelEconomy milageOfNewCar = new FuelEconomy();

            milageOfNewCar.milesPerGallon = Convert.ToDecimal(milageTxtBox.Text);

            Weight weightOfNewCar = new Weight();

            weightOfNewCar.kilograms = Convert.ToDecimal(weightTxtBox.Text);

            Volume fuelCapacityOfNewCar = new Volume();

            fuelCapacityOfNewCar.litres = Convert.ToDecimal(fuelCapacityTxtBox.Text);

            carServicesObj.Add(vehicleNameTxtBox.Text, numberPlateTxtBox.Text, carTypeOfNewCar,
                               milageOfNewCar, weightOfNewCar, fuelCapacityOfNewCar,
                               Convert.ToInt32(passengerCapacityTxtBox.Text));

            Response.Redirect("CarWebPageView.aspx");
        }
コード例 #14
0
        public Lorry Add(string vehicleName, string numberPlate, FuelEconomy milage, Weight weight, bool hasLoad,
                         Weight loadWeight, Volume maximumFuel, int maximumPassengers)
        {
            Lorry lorryToAdd = new Lorry(vehicleName, numberPlate, milage, weight, hasLoad, loadWeight,
                                         maximumFuel, maximumPassengers);

            using (var session = NHibernateHelper.OpenSession())
            {
                using (var tx = session.BeginTransaction())
                {
                    session.Save(lorryToAdd);
                    tx.Commit();
                }
            }
            return(lorryToAdd);
        }
コード例 #15
0
        public Motorbike Add(string vehicleName, string numberPlate, FuelEconomy milage,
                             Weight weight, Volume maximumFuel, int maximumPassengers, bool sideCar)
        {
            Motorbike motorbikeToAdd = new Motorbike(vehicleName, numberPlate, milage, weight, maximumFuel
                                                     , maximumPassengers, sideCar);

            using (var session = NHibernateHelper.OpenSession())
            {
                using (var tx = session.BeginTransaction())
                {
                    session.Save(motorbikeToAdd);
                    tx.Commit();
                }
            }
            return(motorbikeToAdd);
        }
コード例 #16
0
        public Car Add(string vehicleName, string numberPlate, Car.CarType carType, FuelEconomy milage,
                       Weight weight, Volume maximumFuel, int maximumPassengers)
        {
            Car carToAdd = new Car(vehicleName, numberPlate, carType, milage, weight, maximumFuel
                                   , maximumPassengers);

            using (var session = NHibernateHelper.OpenSession())
            {
                using (var tx = session.BeginTransaction())
                {
                    session.Save(carToAdd);
                    tx.Commit();
                }
            }
            return(carToAdd);
        }
コード例 #17
0
 static void PrintFuelEconomy(FuelEconomy economy)
 {
     helper.PrintColorText(economy.ToString(), ConsoleColor.DarkBlue);
     Console.WriteLine();
 }
コード例 #18
0
 static void PrintFuelEconomy(FuelEconomy economy)
 {
     helper.PrintColorText(economy.ToString(), ConsoleColor.DarkBlue);
     Console.WriteLine();
 }
コード例 #19
0
        public void Add()
        {
            Console.WriteLine("Add lorry");
            Console.Write("Name: ");
            string vehicleName = Console.ReadLine();

            string numberPlateEntry, numberPlate = null;

            while (numberPlate == null)
            {
                Console.Write("Number plate: ");
                numberPlateEntry = Console.ReadLine().Replace(" ", "");
                if (numberPlateEntry.Length != 7)
                {
                    Console.WriteLine("Invalid numberplate length");
                }
                else
                {
                    numberPlate = numberPlateEntry;
                }
            }

            Console.Write("Milage (Miles/Gallon): ");
            FuelEconomy milage = new FuelEconomy();

            milage.milesPerGallon = Convert.ToDecimal(Console.ReadLine());

            Console.Write("Weight (kg): ");
            Weight weight = new Weight();

            weight.kilograms = Convert.ToDecimal(Console.ReadLine());

            bool   hasLoad = false, validLoadInput = false;
            Weight loadWeight = new Weight();

            while (!validLoadInput)
            {
                Console.Write("Has load (Y/N):");
                switch (Console.ReadKey().KeyChar)
                {
                case 'y':
                    hasLoad        = true;
                    validLoadInput = true;
                    Console.Write("Load weight (kg): ");
                    loadWeight.kilograms = Convert.ToDecimal(Console.ReadLine());
                    break;

                case 'n':
                    hasLoad        = false;
                    validLoadInput = true;
                    break;

                default:
                    Console.WriteLine("\nInvalid input");
                    break;
                }
            }

            Console.Write("Maximum fuel (litres): ");
            Volume maximumFuel = new Volume();

            maximumFuel.litres = Convert.ToDecimal(Console.ReadLine());

            Console.Write("Maximum passengers: ");
            int maximumPassengers = Convert.ToInt32(Console.ReadLine());

            Lorry addedLorry = lorryServicesObj.Add(vehicleName, numberPlate, milage, weight, hasLoad,
                                                    loadWeight, maximumFuel, maximumPassengers);

            SelectById(addedLorry.Id);
        }
コード例 #20
0
        public void Add()
        {
            Console.WriteLine("Add motorbike");
            Console.Write("Name: ");
            string vehicleName = Console.ReadLine();

            string numberPlateEntry, numberPlate = null;

            while (numberPlate == null)
            {
                Console.Write("Number plate: ");
                numberPlateEntry = Console.ReadLine().Replace(" ", "");
                if (numberPlateEntry.Length != 7)
                {
                    Console.WriteLine("Invalid numberplate length");
                }
                else
                {
                    numberPlate = numberPlateEntry;
                }
            }

            Console.Write("Milage (Miles/Gallon): ");
            FuelEconomy milage = new FuelEconomy();

            milage.milesPerGallon = Convert.ToDecimal(Console.ReadLine());

            Console.Write("Weight (kg): ");
            Weight weight = new Weight();

            weight.kilograms = Convert.ToDecimal(Console.ReadLine());

            Console.Write("Maximum fuel (litres): ");
            Volume maximumFuel = new Volume();

            maximumFuel.litres = Convert.ToDecimal(Console.ReadLine());

            Console.Write("Maximum passengers: ");
            int maximumPassengers = Convert.ToInt32(Console.ReadLine());

            bool sideCar = false, sideCarValidInput = false;

            while (!sideCarValidInput)
            {
                Console.Write("Sidecar (Y/N):");
                switch (Console.ReadKey().KeyChar)
                {
                case 'y':
                    sideCar           = true;
                    sideCarValidInput = true;
                    break;

                case 'n':
                    sideCar           = true;
                    sideCarValidInput = true;
                    break;

                default:
                    Console.WriteLine("\nInvalid input");
                    break;
                }
            }

            Motorbike addedMotorbike = motorbikeServicesObj.Add(vehicleName, numberPlate, milage, weight, maximumFuel,
                                                                maximumPassengers, sideCar);

            SelectById(addedMotorbike.Id);
        }
コード例 #21
0
        public void Add()
        {
            Console.WriteLine("Add car");
            Console.Write("Name: ");
            string vehicleName = Console.ReadLine();

            string numberPlateEntry, numberPlate = null;

            while (numberPlate == null)
            {
                Console.Write("Number plate: ");
                numberPlateEntry = Console.ReadLine().Replace(" ", "");
                if (numberPlateEntry.Length != 7)
                {
                    Console.WriteLine("Invalid numberplate length");
                }
                else
                {
                    numberPlate = numberPlateEntry;
                }
            }

            Console.WriteLine("1. Hatchback");
            Console.WriteLine("2. Sedan");
            Console.WriteLine("3. SUV");
            Console.WriteLine("4. Coupe");
            Console.WriteLine("5. Convertible");

            Car.CarType carType = Car.CarType.Unknown;
            while (carType == Car.CarType.Unknown)
            {
                Console.Write("Car type: ");
                switch (Console.ReadKey(true).KeyChar)
                {
                case '1':
                    carType = Car.CarType.Hatchback;
                    Console.WriteLine("Hatchback");
                    break;

                case '2':
                    carType = Car.CarType.Sedan;
                    Console.WriteLine("Sedan");
                    break;

                case '3':
                    carType = Car.CarType.SUV;
                    Console.WriteLine("SUV");
                    break;

                case '4':
                    carType = Car.CarType.Coupe;
                    Console.WriteLine("Coupe");
                    break;

                case '5':
                    carType = Car.CarType.Convertible;
                    Console.WriteLine("Convertible");
                    break;

                default:
                    Console.WriteLine("Invalid input");
                    break;
                }
            }
            Console.Write("Milage (Miles/Gallon): ");
            FuelEconomy milage = new FuelEconomy();

            milage.milesPerGallon = Convert.ToDecimal(Console.ReadLine());

            Console.Write("Weight (kg): ");
            Weight weight = new Weight();

            weight.kilograms = Convert.ToDecimal(Console.ReadLine());

            Console.Write("Maximum fuel (litres): ");
            Volume maximumFuel = new Volume();

            maximumFuel.litres = Convert.ToDecimal(Console.ReadLine());

            Console.Write("Maximum passengers: ");
            int maximumPassengers = Convert.ToInt32(Console.ReadLine());

            Car addedCar = carServicesObj.Add(vehicleName, numberPlate, carType, milage, weight, maximumFuel,
                                              maximumPassengers);

            SelectById(addedCar.Id);
        }