예제 #1
0
 public void PrintInfoSouthHarbor()
 {
     SouthHarbour.Text = "";
     foreach (var item in Harbour.PrintHarbourInfo(2))
     {
         SouthHarbour.Text += item;
     }
 }
예제 #2
0
 public void PrintInfoNorthHarbour()
 {
     NorthHarbour.Text = "";
     foreach (var item in Harbour.PrintHarbourInfo(1))
     {
         NorthHarbour.Text += item;
     }
 }
예제 #3
0
        public MainWindow()
        {
            InitializeComponent();

            Counter.NumberOfDeclinedBoatsEachDay = 0;
            Counter.NumberOfDeclinedBoatsSinceStartOfSimulation = 0;
            Counter.NumberOfNewBoatsPerUdate = 5;
            //if file path doesent exist hide button
            if (!File.Exists("theharbour.txt"))
            {
                PreviousSimulation.Visibility = Visibility.Hidden;
            }
            HarbourAdministration.BoatsComingToHarbour = new List <Boat>();
            Harbour.CreateWharfPlacesInHArbour();
            Harbour.BoatsInHarbour = new List <Boat>();
        }
예제 #4
0
        private void RunProgram(int numberOfDays)
        {
            int count = 0;

            while (count < numberOfDays)
            {
                Counter.NumberOfDeclinedBoatsEachDay = 0;
                Harbour.DecreaseDaysLeftForBoatsAtWharf();
                Harbour.BoatsInHarbour = Harbour.DecreaseDaysLeftForBoatsInHarbour();
                HarbourAdministration.BoatsComingToHarbour = Boat.CreateNewBoats(Counter.NumberOfNewBoatsPerUdate);
                HarbourAdministration.DeclinedBoats        = new List <Boat>();

                foreach (var boat in HarbourAdministration.BoatsComingToHarbour)
                {
                    bool placeFree = boat.IsTherePLaceForBoatInHarbour();
                    if (placeFree)
                    {
                        int bestPlace = boat.CheckForBestPlaceInHarbour();
                        boat.PlaceBoatAtWharf(bestPlace);
                        Harbour.BoatsInHarbour.Add(boat);
                    }
                    else
                    {
                        HarbourAdministration.DeclinedBoats.Add(boat);
                        Counter.NumberOfDeclinedBoatsEachDay++;
                    }
                }
                Counter.NumberOfDeclinedBoatsSinceStartOfSimulation += Counter.NumberOfDeclinedBoatsEachDay;
                Counter.DaysSinceStartOfSimulation++;
                if (Counter.DaysSinceStartOfSimulation > 0)
                {
                    PreviousSimulation.Visibility = Visibility.Hidden;
                }
                count++;
            }
            CreateAndDisplayPicturesExeptForRowingBoat();
            CreateDisplayRowingBoatPictures();
            PrintInfoHarbour();
            PrintInfoNorthHarbour();
            PrintInfoSouthHarbor();

            HarbourAdministration.WriteInformationToFile(Harbour.WharfPlacesInHarbour, Harbour.BoatsInHarbour);
        }
예제 #5
0
        private void Click_NewSimulation(object sender, RoutedEventArgs e)
        {
            if (File.Exists("theharbour.txt"))
            {
                PreviousSimulation.Visibility = Visibility.Visible;
            }

            foreach (var boat in Harbour.BoatsInHarbour)
            {
                boat.ImageBoat.Visibility = Visibility.Hidden;
            }
            InformationHarbour.Text = "";
            NorthHarbour.Text       = "";
            SouthHarbour.Text       = "";

            Counter.DaysSinceStartOfSimulation = 0;
            Counter.NumberOfDeclinedBoatsSinceStartOfSimulation = 0;

            Harbour.CreateWharfPlacesInHArbour();
            Harbour.BoatsInHarbour = new List <Boat>();
        }