Exemple #1
0
        /// <summary>
        /// Lägger till en ny båt
        /// </summary>
        /// <returns>Om båten blev inlagd eller ej</returns>
        private static bool AddBoat()
        {
            Console.Clear();
            TextColor("Ny båt:\n", ConsoleColor.White);
            string color, owner, manufacturer, regno, name, registrationport, imo;
            double height, length, width, weight;
            int    maxspeed, numberofengines;

            name = UserInput.AskForString("Ange båtens namn: ");
            UserInput.GeneralInfo(out color, out owner, out height, out length, out width, out manufacturer, out maxspeed, out regno, out weight);
            numberofengines  = UserInput.AskForInt("Antal motorer: ");
            registrationport = UserInput.AskForString("Ange hemmahamn: ");
            imo = UserInput.AskForString("Ange IMO-kod: ");
            Flags     flag     = UserInput.AskForFlag();;
            Boattypes boattype = UserInput.AskForBoattype();

            bool succeed = garage.Add(new Boat(color, owner, weight, width, height, length, maxspeed, manufacturer, numberofengines, flag, boattype, name, registrationport, regno, imo));

            ShowResponse(succeed, "Båten har lagts till", "Åtgärden misslyckades (Har du redan registrerat angivet registreringsnummer?)");

            return(succeed);
        }
Exemple #2
0
        /// <summary>
        /// Frågar efter en båttyp
        /// </summary>
        /// <returns>En båttyp</returns>
        public static Boattypes AskForBoattype()
        {
            Boattypes boatType = 0;

            bool validInput = false;

            do
            {
                Console.Write("Välj alternativ (F=Färja, M=Motorbåt, S=Segelbåt): ");
                char   ch     = Console.ReadKey().KeyChar;
                string choice = ch.ToString().ToUpper();   // valet får inte vara case-sensitive

                switch (choice)
                {
                case "F":
                    boatType   = Boattypes.Ferry;
                    validInput = true;
                    break;

                case "M":
                    boatType   = Boattypes.Motorboat;
                    validInput = true;
                    break;

                case "S":
                    boatType   = Boattypes.SailingBoat;
                    validInput = true;
                    break;

                default:
                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.WriteLine("\n\nOgiltigt val, försök igen!\n");
                    Console.ForegroundColor = ConsoleColor.Gray;
                    break;
                }
            } while (!validInput);

            return(boatType);
        }
Exemple #3
0
 public Boat(string color, string owner, double weight, double width, double height, double length, int maxspeed, string manufacturer, int numberofengines, Flags flag, Boattypes boattype, string name, string registrationport, string regno, string imo, bool parked = true) : base(color, owner, weight, width, height, length, maxspeed, manufacturer, regno, parked)
 {
     this.NumberOfEngines  = numberofengines;
     this.Flag             = flag;
     this.Name             = name;
     this.RegistrationPort = registrationport;
     this.IMO      = imo;
     this.Boattype = boattype;
 }