예제 #1
0
        public static CargoShip CreateCargoShip()
        {
            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);
            }
            CargoShip cargoShip = new CargoShip();

            cargoShip.IDNumber          = "L-" + stringBuilder.ToString();
            cargoShip.MaxSpeed          = r.Next(1, 20 + 1);
            cargoShip.Weight            = r.Next(3000, 20000 + 1);
            cargoShip.AmountOfDockPlace = 4;
            cargoShip.UniqueProperty    = "Containers: " + r.Next(0, 500 + 1);
            cargoShip.DaysInDock        = 6;
            cargoShip.BoatType          = "Lastfartyg";
            cargoShip.InDock            = true;


            return(cargoShip);
        }
예제 #2
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);
        }
예제 #3
0
        public void AddCargoShipArrival(Boat[] harbourList, List <Boat> rejectedBoats, int currentDay)
        {
            CargoShip cargoShip = new CargoShip();

            cargoShip.DayOfArrival = currentDay;
            cargoShip.DayToLeave   = currentDay + cargoShip.DaysInHarbour;
            RegisterBoat(harbourList, rejectedBoats, cargoShip);
        }
예제 #4
0
        private Boat CreateCargoShip()
        {
            CargoShip cargoShip = new CargoShip(
                name: $"L-{RegistrationLetters()}",
                type: "Lastfartyg",
                portSpaceRequired: 4,
                daysLeftInHarbor: 6
                );

            return(cargoShip);
        }
예제 #5
0
        public static CargoShip CreateCargoShip()
        {
            CargoShip cg = new CargoShip();

            cg.Id                    = GenerateId("L");
            cg.Weight                = GenerateWeight(3000, 20000);
            cg.MaxSpeed              = GenerateMaxSpeed(20);
            cg.NumberOfContainers    = GenerateNumberOfContainers(500);
            cg.NumberOfDaysInHarbour = 6;
            cg.NumberOfSlots         = 4;

            return(cg);
        }
예제 #6
0
파일: Program.cs 프로젝트: AdinSar/Hamnen
        private static void AddCargoShiptToList(List <Boat> boatlist)
        {
            for (int i = boatlist.Count - 1; i >= 4; i--)
            {
                if (boatlist[i].InDock is false && boatlist[i - 1].InDock is false && boatlist[i - 2].InDock is false && boatlist[i - 3].InDock is false && boatlist[i].Place % 1 == 0 && boatlist[i - 1].Place % 1 == 0 && boatlist[i - 2].Place % 1 == 0 && boatlist[i - 3].Place % 1 == 0)

                {
                    CargoShip cargoShip = CargoShip.CreateCargoShip();
                    boatlist[i].BoatType              = cargoShip.BoatType;
                    boatlist[i].IDNumber              = cargoShip.IDNumber;
                    boatlist[i].Weight                = cargoShip.Weight;
                    boatlist[i].MaxSpeed              = cargoShip.MaxSpeed;
                    boatlist[i].DaysInDock            = cargoShip.DaysInDock;
                    boatlist[i].AmountOfDockPlace     = cargoShip.AmountOfDockPlace;
                    boatlist[i].InDock                = cargoShip.InDock;
                    boatlist[i].UniqueProperty        = cargoShip.UniqueProperty;
                    boatlist[i - 1].BoatType          = cargoShip.BoatType;
                    boatlist[i - 1].IDNumber          = cargoShip.IDNumber;
                    boatlist[i - 1].Weight            = cargoShip.Weight;
                    boatlist[i - 1].MaxSpeed          = cargoShip.MaxSpeed;
                    boatlist[i - 1].DaysInDock        = cargoShip.DaysInDock;
                    boatlist[i - 1].AmountOfDockPlace = cargoShip.AmountOfDockPlace;
                    boatlist[i - 1].InDock            = cargoShip.InDock;
                    boatlist[i - 1].UniqueProperty    = cargoShip.UniqueProperty;
                    boatlist[i - 2].BoatType          = cargoShip.BoatType;
                    boatlist[i - 2].IDNumber          = cargoShip.IDNumber;
                    boatlist[i - 2].Weight            = cargoShip.Weight;
                    boatlist[i - 2].MaxSpeed          = cargoShip.MaxSpeed;
                    boatlist[i - 2].DaysInDock        = cargoShip.DaysInDock;
                    boatlist[i - 2].AmountOfDockPlace = cargoShip.AmountOfDockPlace;
                    boatlist[i - 2].InDock            = cargoShip.InDock;
                    boatlist[i - 2].UniqueProperty    = cargoShip.UniqueProperty;
                    boatlist[i - 3].BoatType          = cargoShip.BoatType;
                    boatlist[i - 3].IDNumber          = cargoShip.IDNumber;
                    boatlist[i - 3].Weight            = cargoShip.Weight;
                    boatlist[i - 3].MaxSpeed          = cargoShip.MaxSpeed;
                    boatlist[i - 3].DaysInDock        = cargoShip.DaysInDock;
                    boatlist[i - 3].AmountOfDockPlace = cargoShip.AmountOfDockPlace;
                    boatlist[i - 3].InDock            = cargoShip.InDock;
                    boatlist[i - 3].UniqueProperty    = cargoShip.UniqueProperty;


                    return;
                }
            }
        }
예제 #7
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);
            }
        }