Beispiel #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);
        }
Beispiel #2
0
        public static RowBoat CreateRowBoat()
        {
            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);
            }
            RowBoat rowBoat = new RowBoat();

            rowBoat.IDNumber          = "R-" + stringBuilder.ToString();
            rowBoat.MaxSpeed          = r.Next(1, 3 + 1);
            rowBoat.Weight            = r.Next(100, 300 + 1);
            rowBoat.AmountOfDockPlace = 0.5;
            rowBoat.UniqueProperty    = "Max Antal pers: " + r.Next(1, 6 + 1);
            rowBoat.DaysInDock        = 1;
            rowBoat.BoatType          = "Roddbåt";
            rowBoat.InDock            = true;


            return(rowBoat);
        }
Beispiel #3
0
        private static void AddRowBoatToList(List <Boat> boatlist)
        {
            for (int i = 0; i < boatlist.Count; i++)
            {
                if (boatlist[i].Place % 1 == 0.5)
                {
                    RowBoat rowBoat = RowBoat.CreateRowBoat();
                    boatlist[i].BoatType          = rowBoat.BoatType;
                    boatlist[i].IDNumber          = rowBoat.IDNumber;
                    boatlist[i].Weight            = rowBoat.Weight;
                    boatlist[i].MaxSpeed          = rowBoat.MaxSpeed;
                    boatlist[i].DaysInDock        = rowBoat.DaysInDock;
                    boatlist[i].AmountOfDockPlace = rowBoat.AmountOfDockPlace;
                    boatlist[i].InDock            = rowBoat.InDock;
                    boatlist[i].UniqueProperty    = rowBoat.UniqueProperty;

                    return;
                }
            }
            for (int i = 0; i < boatlist.Count; i++)
            {
                if (boatlist[i].InDock is false)
                {
                    if (boatlist[i].Place % 1 == 0)
                    {
                        Boat b = new Boat();
                        b.Place          = boatlist[i].Place + 0.5;
                        b.BoatType       = "Tomt";
                        b.InDock         = false;
                        b.UniqueProperty = "-";
                        b.IDNumber       = "-";
                        boatlist.Add(b);

                        RowBoat rowBoat = RowBoat.CreateRowBoat();
                        boatlist[i].BoatType          = rowBoat.BoatType;
                        boatlist[i].IDNumber          = rowBoat.IDNumber;
                        boatlist[i].Weight            = rowBoat.Weight;
                        boatlist[i].MaxSpeed          = rowBoat.MaxSpeed;
                        boatlist[i].DaysInDock        = rowBoat.DaysInDock;
                        boatlist[i].AmountOfDockPlace = rowBoat.AmountOfDockPlace;
                        boatlist[i].InDock            = rowBoat.InDock;
                        boatlist[i].UniqueProperty    = rowBoat.UniqueProperty;

                        return;
                    }
                }
            }
        }
Beispiel #4
0
 private static bool FindFreeSpotRowBoat(RowBoat rowBoat) //skickar in en roddbåt i taget.
 {
     foreach (Dock dock in Docks)                         //kollar en dock i taget 1-64(index 0-63)
     {
         for (int i = 0; i < dock.Boats.Length; i++)      //
         {
             if (dock.Boats[i] == null)
             {
                 dock.Boats[i] = rowBoat;//= gör såhär och null i remove // lägger till rowboat
                 return(true);
             }
         }
     }
     RejectedBoats.Add(rowBoat); //funkar detta?
     return(false);
 }