private static void CarBuilder() { string userCarType = In.GetString("Provide a car type (car, turck van)"); int userNumberOfDoors = In.GetInt("Provide the number of doors: "); int userCarSpeed = In.GetInt("Provide car speed: "); Car car = new Car(); car.CarType = userCarType; car.NumberOfDooers = userNumberOfDoors; car.Speed = userCarSpeed; Out.P("************************"); Out.P($"The car created is: \n {car.CarType} \n Number of doors {car.NumberOfDooers} \n Car speed: {car.Speed} \n Car price: {car.Price.GetValueOrDefault()}"); Out.P("************************ \n"); carList.Add(car); Out.P($"{carList.Count} cars in my garage"); string userShowCars = In.GetString("Do you want to see list of the cars (y/n)"); if (userShowCars == "y") { foreach (Car cr in carList) { Out.P($"\n Car Type: {cr.CarType} \n Number of doors: {cr.NumberOfDooers} \n Car Speed {cr.Speed} \n Car Price {cr.Price.GetValueOrDefault().ToString("c")}"); } } }
private static void CarBuilder() { string userCarType = In.GetString("Provide a car type (ie Car, Truck, Van:)", true); int userNumberOfDoors = In.GetInt("Provide the number of doors: "); int userCarSpeed = In.GetInt("Provide the car speed: "); Car car = new Car(); car.CarType = userCarType; car.NumberOfDoors = userNumberOfDoors; car.Speed = userCarSpeed; Out.P("**********"); Out.P($"The car created is:\n" + $"Type: {car.CarType}\n" + $"Number of doors: {car.NumberOfDoors}\n" + $"Speed: {car.Speed}\n" + $"Price: {car.Price.GetValueOrDefault()}"); Out.P("**********\n"); myCars.Add(car); Out.P($"I have a car count in my list of: {myCars.Count}"); if (In.GetString("Do you wnat to list all cars? y/n ").ToUpper()[0] == 'Y') { Out.P(""); foreach (Car c in myCars) { Out.P($"Type: {c.CarType} Number of doors: {c.NumberOfDoors} Speed: {c.Speed} Price: {c.Price.GetValueOrDefault()}"); } } }
private static void CarBuilder() { string userCarType = In.GetString("Provide a car type (ie Car, Truck, Van: \n"); int userNumberOfDoors = In.GetInt("Provide the number of doors: \n"); int userSpeed = In.GetInt("Provide car speed: \n"); Car car = new Car(); car.CarType = userCarType; car.NumberOfDoors = userNumberOfDoors; car.Speed = userSpeed; Out.P("***********"); Out.P($"The car created is:\nType: {car.CarType}\nNumber of doors: {car.NumberOfDoors}\nSpeed: {car.Speed}\nPrice: {car.Price.GetValueOrDefault()}"); Out.P("***********\n"); myCars.Add(car); Out.P($"I have a car count in my list of: {myCars.Count}"); /*After added to the list: * Prompt the user: "******" * If yes: Loop throught the list of cars and print each car with all properties * (right after the car count) * PRICE FORMAT TO CURRENCY */ string userGetList = In.GetString("Do you want to list all cars?\n"); if (userGetList.ToUpper() == "Y") { foreach (Car c in myCars) { Out.P("**************"); Out.P($"Type: {c.CarType}" + $" Number of Doors: {c.NumberOfDoors}" + $" Speed: {c.Speed}" + $" Year: {c.Year}" + $" Price: {c.Price.GetValueOrDefault().ToString("c")}"); } Out.P("**************"); } }
private static void CarBuilder() { string userCarType = In.GetString("Provide a car type (ie Car, Truck, Van):\n"); int userNumberOfDoors = In.GetInt("Provide the number of doors: "); int userCarSpeed = In.GetInt("Provide the car speed: "); Car car = new Car(); car.CarType = userCarType; car.NumberOfDoors = userNumberOfDoors; car.Speed = userCarSpeed; Out.P("**************"); Out.P($"The Car created is:\nType: { car.CarType}" + $"\nNumber of doors: {car.NumberOfDoors}" + $"\nSpeed: {car.Speed}" + $"\nYear: {car.Year}" + $"\nPrice: {car.Price.GetValueOrDefault()}"); Out.P("**************\n"); myCars.Add(car); Out.P($"I have a car count in my list of: {myCars.Count}"); string userType = In.GetString($"Do you want to list all cars? y/n\n"); Out.P("**************\n"); if (userType.ToLower() == "y") { foreach (Car c in myCars) { Out.P("**********************"); Out.P($"Type: {c.CarType}" + $"Number Of Doors: {c.NumberOfDoors}" + $"Car Speed: {c.Speed}" + $"Car Year: {c.Year}" + $"Car Price: {c.Price.GetValueOrDefault().ToString("c")}"); } Out.P("**********************"); } }
private static void CarBuilder() { string userCarType = In.GetString("Provide a car type (i.e car, truck, van) \n"); int userNumberOfDoors = In.GetInt("Provide number of doors:"); int userCarSpeed = In.GetInt("Provide car speed:"); string question = In.GetString("Do you want to print list of all cars? y/n"); car car = new car(); car.CarType = userCarType; car.NumberOfDoors = userNumberOfDoors; car.Speed = userCarSpeed; Out.P("*************************"); Out.P($"The car created is: \n" + $"Type: {car.CarType} \n" + $"Doors: {car.NumberOfDoors} \n" + $"Speed: {car.Speed} \n" + $"Price: {car.Price.GetValueOrDefault()} \n"); Out.P("*************************"); //print myCars.Add(car); Out.P($"I have a car count in my list of: {myCars.Count}"); //Out.P("Do you want to list all cars y/n"); if (question.ToLower() == "y") { foreach (car item in myCars) { Out.P($"Car type: {item.CarType} Numb of doors: {item.NumberOfDoors} Speed: {item.Speed} Price: {item.Price.GetValueOrDefault().ToString("c")} \n"); } } //prompt the user "Do you want to list all cars" yes or no //if user enter yes => loop the list of cars => print each car with all //properties //if user enter no => don't print }
private static void CarBuilder() { string userCarType = In.GetString("Provice a car Type (ice Car, Truck, Van:\n"); int userNumberOfDoors = In.GetInt("Provice the number of doors: "); int userCarSpeed = In.GetInt("Provide the car speed: "); Car car = new Car(); car.CarType = userCarType; car.NumOffDoors = userNumberOfDoors; car.Speed = userCarSpeed; Out.P("****************************"); Out.P($"The car created is:\nType: {car.CarType}" + $"\nNumber of doors: {car.NumOffDoors}" + $"\nSpeed: {car.Speed}" + $"\nPrice: {car.Price.GetValueOrDefault()}"); Out.P("****************************"); myCars.Add(car); //Vamos imprimir qtos carros tenho na minha colecao Out.P($"I have a car count in my list of: {myCars.Count}"); string countCard = In.GetString("Do you want to list all cars? y/n:"); if (countCard.ToLower() == "y") { foreach (Car item in myCars) { Out.P($"Type: {item.CarType}\n Doors: {item.NumOffDoors}\n Speed: {item.Speed} km/h\n Year: {item.Yeay}\n Price: {item.Price.GetValueOrDefault().ToString("c")}"); } } else { LoadMenu(); } }
private static void CarBuilder() { string userCarType = In.GetString("Provide a car type (ie Car, Truck, Van: \n"); int userNumberOfDoors = In.GetInt("Provide the number of doors: \n"); int userCarSpeed = In.GetInt("Provide the car speed: "); Car car = new Car(); car.CarType = userCarType; car.NumberOfDoors = userNumberOfDoors; car.Speed = userCarSpeed; Out.P("------------- \n"); Out.P($"The Car created is: \nType: {car.CarType} \nNumber of doors: {car.NumberOfDoors} \n" + $"Speed: {car.Speed}\nPrice: {car.Price.GetValueOrDefault()}\n"); Out.P("------------- \n"); myCars.Add(car); Out.P($"I have {myCars.Count} cars in my list."); string entry = In.GetString("Do you want to list all cars? y or n"); if (entry == "y") { for (int i = 0; i < myCars.Count; i++) { Out.P($"Car number: {i + 1} \nCar Type: {myCars[i].CarType}\nNumber of doors: {myCars[i].NumberOfDoors}\n" + $"Speed: {myCars[i].Speed}\nPrice: {myCars[i].Price.GetValueOrDefault().ToString("c")}\n"); } } else { return; } }