Пример #1
0
        public static void GeneratingNewBoats()
        {
            for (int i = 0; i < vesselsPerDay; i++)
            {
                approachingVessel = random.Next(1, 5 + 1);
                switch (approachingVessel)
                {
                case 1:
                    Boat rowingBoat = new RowingBoat($"Roddbåt\t", $"R-{GetID()}", GetValue(100, 300), GetValue(0, 3), tokenSign: "R", GetValue(1, 6), 1);
                    Harbour.PlaceVessel(1, rowingBoat);
                    break;

                case 2:
                    Boat motorBoat = new MotorBoat($"Motorbåt", $"M-{GetID()}", GetValue(200, 3000), GetValue(0, 60), tokenSign: "M", GetValue(10, 1000), 3);
                    Harbour.PlaceVessel(1, motorBoat);
                    break;

                case 3:
                    Boat sailingBoat = new SailingBoat($"Segelbåt", $"S-{GetID()}", GetValue(800, 6000), GetValue(0, 12), tokenSign: "S", GetValue(10, 60), 4);
                    Harbour.PlaceVessel(2, sailingBoat);
                    break;

                case 4:
                    Boat catamaran = new Catamaran($"Katamaran", $"K-{GetID()}", GetValue(1200, 8000), GetValue(0, 12), tokenSign: "K", GetValue(1, 4), 3);
                    Harbour.PlaceVessel(3, catamaran);
                    break;

                case 5:
                    Boat cargoShip = new CargoShip($"Lastfartyg", $"L-{GetID()}", GetValue(3000, 20000), GetValue(0, 20), tokenSign: "L", GetValue(0, 500), 6);
                    Harbour.PlaceVessel(4, cargoShip);
                    break;
                }
            }
        }
Пример #2
0
        public static void Run()
        {
            bool isRunning = true;
            bool newLoad   = true;

            Harbour.EmptyHarbour();
            do
            {
                Console.WriteLine("Välkommen till hamnen!\n\n[1] Ny simulering\n[2] Ladda senaste simulering");
                Console.Write("Välj: ");
                ConsoleKey newOrLoad = Console.ReadKey().Key;
                Console.Clear();
                switch (newOrLoad)
                {
                case ConsoleKey.D1:
                    Console.WriteLine("Startar från dag 0!");
                    newLoad = false;
                    Thread.Sleep(2000);
                    break;

                case ConsoleKey.D2:
                    Harbour.LoadData();
                    newLoad = false;
                    break;

                default:
                    Console.WriteLine("Vänligen välj [1] eller [2]!");
                    Thread.Sleep(1000);
                    break;
                }
            } while (newLoad);
            while (isRunning)
            {
                newLoad = false;
                Console.Clear();
                Harbour.WriteOutHarbour();
                ConsoleKey keyChoice = Console.ReadKey().Key;
                Console.Clear();
                switch (keyChoice)
                {
                case ConsoleKey.Enter:
                    break;

                case ConsoleKey.D1:
                    newLoad = true;
                    break;

                case ConsoleKey.D2:
                    isRunning = false;
                    Console.WriteLine("Avslutar!");
                    Thread.Sleep(1000);
                    break;

                default:
                    break;
                }
                if (newLoad)
                {
                    StartOver();
                    Console.WriteLine("Startar om från dag 0!");
                    Thread.Sleep(2000);
                }
                else if (isRunning == false)
                {
                    Harbour.SaveData();
                }
                else
                {
                    Harbour.DecreaseCounter();
                    Boat.GeneratingNewBoats();
                    Harbour.SaveData();
                }
            }
        }
Пример #3
0
 private static void StartOver()
 {
     File.WriteAllText("savedData.txt", string.Empty);
     Harbour.EmptyHarbour();
     Harbour.daysPassed = 0;
 }