示例#1
0
        public Bil OpretBil()
        {
            try
            {
                Console.WriteLine("Indtast venligst registreringsnummer");
                string regnr = Console.ReadLine();
                Console.WriteLine("Indtast venligst mærke");
                string mærke = Console.ReadLine();
                Console.WriteLine("Indtast venligst model");
                string model = Console.ReadLine();
                Console.WriteLine("Indtast venligst årgang");
                int årgang = int.Parse(Console.ReadLine());
                Console.WriteLine("Indtast venligst antal kørte kilometer");
                int km = int.Parse(Console.ReadLine());
                Console.WriteLine("Indtast venligst brændstoftype (ID)");
                Brændstof brændstof = (Brændstof)int.Parse(Console.ReadLine());
                Console.WriteLine("Indtast venligst kundeID");
                int kundeid = int.Parse(Console.ReadLine());

                bil = new Bil(regnr, mærke, model, årgang, km, brændstof, kundeid);
                bil.Insert();
            }
            catch (FormatException)
            {
                Console.WriteLine("Forkert input. Tryk på en vilkårlig tast for at vende tilbage til hovedmenuen.");
                Console.ReadKey();
            }
            catch (Exception)
            {
                Console.WriteLine("Det var en upser! Smut pomfrit");
                Console.ReadKey();
            }
            return(bil);
        }