Exemple #1
0
        public static List <Boat> CreateFiveMoreBoats() //skapar 5 båtar
        {
            List <Boat> boats = new List <Boat>();

            for (int i = 0; i < 5; i++)
            {
                int r = random.Next(0, 4);
                if (r == 0)
                {
                    RowBoat rb = new RowBoat();
                    boats.Add(rb);
                }
                if (r == 1)
                {
                    MotorBoat mb = new MotorBoat();
                    boats.Add(mb);
                }
                if (r == 2)
                {
                    SailBoat sb = new SailBoat();
                    boats.Add(sb);
                }
                if (r == 3)
                {
                    CargoShip cg = new CargoShip();
                    boats.Add(cg);
                }
            }
            return(boats);
        }
Exemple #2
0
        public static MotorBoat CreateMotorBoat()
        {
            StringBuilder stringBuilder = new StringBuilder();
            Random        r             = new Random();
            char          letter;
            int           lenght = 3;

            for (int i = 0; i < lenght; i++)
            {
                double flt   = r.NextDouble();
                int    shift = Convert.ToInt32(Math.Floor(25 * flt));
                letter = Convert.ToChar(shift + 65);
                stringBuilder.Append(letter);
            }
            MotorBoat motorBoat = new MotorBoat();

            motorBoat.IDNumber          = "M-" + stringBuilder.ToString();
            motorBoat.MaxSpeed          = r.Next(1, 60 + 1);
            motorBoat.Weight            = r.Next(200, 3000 + 1);
            motorBoat.AmountOfDockPlace = 1;
            motorBoat.UniqueProperty    = "Hästkrafter: " + r.Next(10, 1000 + 1) + "hk";
            motorBoat.DaysInDock        = 3;
            motorBoat.BoatType          = "Motorbåt";
            motorBoat.InDock            = true;


            return(motorBoat);
        }
Exemple #3
0
        public Boat CreateMotorBoat()
        {
            MotorBoat motorBoat = new MotorBoat(
                name: $"M-{RegistrationLetters()}",
                type: "Motorbåt",
                portSpaceRequired: 1,
                daysLeftInHarbor: 3
                );

            return(motorBoat);
        }
        public static MotorBoat CreateMotorBoat()
        {
            MotorBoat mb = new MotorBoat();

            mb.Id                    = GenerateId("M");
            mb.Weight                = GenerateWeight(200, 3000);
            mb.MaxSpeed              = GenerateMaxSpeed(60);
            mb.HorsePower            = GenerateHorsePower(10, 1000);
            mb.NumberOfDaysInHarbour = 3;
            mb.NumberOfSlots         = 1;

            return(mb);
        }
Exemple #5
0
        private static void AddMotorBoatToList(List <Boat> boatlist)
        {
            for (int i = 0; i < boatlist.Count; i++)
            {
                if (boatlist[i].InDock is false && boatlist[i].Place % 1 == 0)
                {
                    MotorBoat motorBoat = MotorBoat.CreateMotorBoat();
                    boatlist[i].BoatType          = motorBoat.BoatType;
                    boatlist[i].IDNumber          = motorBoat.IDNumber;
                    boatlist[i].Weight            = motorBoat.Weight;
                    boatlist[i].MaxSpeed          = motorBoat.MaxSpeed;
                    boatlist[i].DaysInDock        = motorBoat.DaysInDock;
                    boatlist[i].AmountOfDockPlace = motorBoat.AmountOfDockPlace;
                    boatlist[i].InDock            = motorBoat.InDock;
                    boatlist[i].UniqueProperty    = motorBoat.UniqueProperty;

                    return;
                }
            }
        }
Exemple #6
0
        static Boat CreateBoat()
        {
            Random random    = new Random();
            int    randomNum = random.Next(1, 4);

            switch (randomNum)
            {
            case 1:
                MotorBoat motorBoat = new MotorBoat();
                return(motorBoat);

            case 2:
                SailingBoat SailingBoat = new SailingBoat();
                return(SailingBoat);

            case 3:
                CargoShip cargoShip = new CargoShip();
                return(cargoShip);

            default:
                return(null);
            }
        }