public string AskForColor() { //todo: formatting and checking Console.Write("\nColor: "); string color = Console.ReadLine(); return(Extra.CAPITALFormatting(color)); }
public string AskForReg() { //todo: formatting and checking Console.Write("\nReg number: "); string regnr = Console.ReadLine(); regnr = Extra.CAPITALFormatting(regnr); if (Lookup(regnr) < 0) { return(regnr); } else { return(null); } //return Extra.CAPITALFormatting(regnr); }
public int RegLookup(string searchReg) { int found = -1; int count = 0; searchReg = Extra.CAPITALFormatting(searchReg); foreach (var ch in garage) { if (searchReg == ch.RegNumber) { return(count); } count++; } return(found); }
void SearchProperties() { Vehicle toSearch = null; Console.WriteLine("\r\n\r\nFill the fields you wanna search, leave rest empty... "); Console.Write("type: "); string type = Extra.NormalFormatting(Console.ReadLine()); //todo: make formatting correct Console.Write("regnr: "); string reg = Extra.CAPITALFormatting(Console.ReadLine()); //todo: check formatting Console.Write("color: "); string color = Extra.CAPITALFormatting(Console.ReadLine().ToUpper()); //todo: check formatting Console.Write("number of wheels: "); string wheels = Console.ReadLine(); //todo: fix checking int nowheels = -1; if (!string.IsNullOrEmpty(wheels)) //nowheels = Int32.tr(wheels); //todo: formatting { if (!Int32.TryParse(wheels, out nowheels)) { Console.WriteLine("unable to parse"); } } if (type == "Airplane") //jag gillar inte den här specifika koden .. { double maxalt = theGarage.AskForMaxAltitude(); toSearch = new Airplane(reg, color, nowheels, maxalt); //todo: add with proper layering } else if (type == "Boat") { double weight = theGarage.AskForWeight(); toSearch = new Boat(reg, color, nowheels, weight); } else if (type == "Bus") { int passengers = theGarage.AskForPassengers(); toSearch = new Bus(reg, color, nowheels, passengers); } else if (type == "Car") { double gasolineconsumption = theGarage.AskForGasolineConsumption(); toSearch = new Car(reg, color, nowheels, gasolineconsumption); } else if (type == "Motorcycle") { double topspeed = theGarage.AskForTopSpeed(); toSearch = new Motorcycle(reg, color, nowheels, topspeed); } else { toSearch = new Vehicle(reg, color, nowheels); } var searchItems = new Queue <Vehicle>(theGarage.Lookup(toSearch.GetType().Name, toSearch.RegNumber, toSearch.Color, toSearch.NoWheels)); while (searchItems.Count > 0) { var t = searchItems.Dequeue(); Console.WriteLine("found: " + t.Color); } }