public Overview() { InitializeComponent(); LoadCar load = new LoadCar(); cars = load.Load(); car = load.LoadSelectedCar(); /*Calculating the tax for each of the cars in car.*/ try { foreach (Car theCar in cars) { if (theCar.CO2gramsPerKilometer != null && theCar.CO2gramsPerKilometer != 0) { TaxCalculator tax = new TaxCalculator(); float? taxCost = tax.CalculateTax(theCar); } } if (car.CO2gramsPerKilometer != null && car.CO2gramsPerKilometer != 0) { TaxCalculator tax = new TaxCalculator(); float? taxCost = tax.CalculateTax(car); } } catch (Exception e) { Console.WriteLine(e.ToString()); } string thisDirectory = Directory.GetCurrentDirectory().ToString(); string fileLoc = thisDirectory + @"\Images\LeafIcon.png"; pictureBox1.Image = Image.FromFile(fileLoc); pictureBox1.SizeMode = PictureBoxSizeMode.StretchImage; /*If the car is null that means that the user has not * yet selected a car to be there main car, in which case we will set the * first car in the array (if it exists) to be the selected car.*/ if (car == null) { /*Checking if the user has added any cars to the list before * if they have we will set the first of these cars to be the selected cars, else * we will display the user with an error message.*/ if (cars != null && cars.Count() > 0) { SaveCar save = new SaveCar(); save.selectedCar(0); //printer so we can print information about the car. CarPrinter printer = new CarPrinter(); string info = printer.carHeader(cars.ElementAt(0)); string details = printer.printcar(cars.ElementAt(0), measurementSystem); CarInfo.Text = info; CarDetails.Text = details; setImage(cars.ElementAt(0).Manufacturer); } /*Else we have no saved cars either so we will * display a messaage to the user saying we have no car.*/ else { setImage("error"); CarInfo.Text = "Error! Please go to Add Car and add your car/cars."; CarDetails.Text = "Error!"; } } //else a saved car does exist so use this instead. else { CarPrinter printer = new CarPrinter(); string info = printer.carHeader(car); string details = printer.printcar(car, measurementSystem); CarInfo.Text = info; CarDetails.Text = details; setImage(car.Manufacturer); } }