예제 #1
0
        private static void Main(string[] args)
        {
            //object met al de functies in voor main program
            var programFunctions = new _ProgramFunctions();
            var lineDrawer       = new _LineDrawer();

            //schrijven van de titel
            var title = "TERRARIUM";

            Console.WriteLine(title);
            Console.Write(lineDrawer.DrawLine(title.Length, '*'));

            //Grootte terrarium vragen met controle input
            //Hier later mogelijk om meerdere terrariums aan te maken via for lus
            //als we input vragen over aantal terrariums te maken
            var     sizeTerrarium = programFunctions.AskSizeTerrarium();
            var     terrarium     = new Terrarium(sizeTerrarium);
            Logboek logboek       = new Logboek(terrarium);

            terrarium.LogBook = logboek;

            // ask user for starting values for Organisms

            double[] StartingValuesOrganisms = programFunctions.AskStartingValuesOrganisms();

            //array aanmaken met first day values
            Console.Clear();
            var arrTerrarium = terrarium.FirstDay(StartingValuesOrganisms);
            var day          = 1;

            // ask type of logbook
            string logbookChoice = programFunctions.AskTypeLog(terrarium, logboek, arrTerrarium);

            //Terrarium tonen op het scherm (first day)
            programFunctions.DrawTitelWithLine(day);
            terrarium.Display(arrTerrarium);
            if (logbookChoice == "simple")
            {
                terrarium.LogBook.Showlogboek();
            }
            else if (logbookChoice == "detailed")
            {
                Console.Write(terrarium.LogBook.ShowExtensiveLogboek(arrTerrarium));
            }
            else
            {
                // no logbook
            }

            //Terrarium tonen op het scherm (first day)

            //infinite loop as long program runs
            while (true)
            {
                programFunctions.AskNextMove(terrarium, arrTerrarium, logboek, logbookChoice);
            }
        }
예제 #2
0
        // ask whether to show limited log, extensive log or not log

        public string AskTypeLog(Terrarium terrarium, Logboek logboek, Organism[,] arrOrganism)
        {
            string consoleInput;

            Console.WriteLine("Show simple, detailed, or no log? (\"simple\", \"detailed\", \"no\")");
            consoleInput = Console.ReadLine();

            while (consoleInput != "simple" && consoleInput != "detailed" && consoleInput != "no")
            {
                Console.WriteLine("Invalid input. Choose between \"simple\", \"detailed\", or \"no\")");
                consoleInput = Console.ReadLine();
            }
            return(consoleInput);
        }
예제 #3
0
        public void AskNextMove(Terrarium terrarium, Organism[,] arrTerrarium, Logboek logboek, string logbookchoice)
        {
            var input    = string.Empty;
            var skipDays = 100;

            Console.WriteLine("Press 'v' and ENTER to show the next day in the terrarium.");
            Console.WriteLine("Press 's' and ENTER to stop the program.");
            Console.WriteLine("Press 'f' and ENTER for fast forward {0} days.", skipDays);
            Console.WriteLine("Press 't' and ENTER for playing a timelapse of {0} days.", skipDays);

            //alles naar upper om zo later klein- en hoofdletter te lezen
            input = Console.ReadLine().ToUpper();

            //switch gebruiken om zo later makkelijker opties toe te voegen
            switch (input)
            {
            case "S":
                Environment.Exit(0);
                break;

            case "V":
                day++;
                DrawTitelWithLine(day);
                terrarium.NextDay(ref arrTerrarium, ref logboek);
                terrarium.Display(arrTerrarium);
                if (logbookchoice == "simple")
                {
                    terrarium.LogBook.Showlogboek();
                }
                else if (logbookchoice == "detailed")
                {
                    Console.Write(terrarium.LogBook.ShowExtensiveLogboek(arrTerrarium));
                }
                else
                {
                    // no logbook
                }
                break;

            case "F":
                for (int i = 0; i < skipDays; i++)
                {
                    day++;
                    terrarium.NextDay(ref arrTerrarium, ref logboek);
                }
                DrawTitelWithLine(day);
                terrarium.Display(arrTerrarium);
                if (logbookchoice == "simple")
                {
                    terrarium.LogBook.Showlogboek();
                }
                else if (logbookchoice == "detailed")
                {
                    Console.Write(terrarium.LogBook.ShowExtensiveLogboek(arrTerrarium));
                }
                else
                {
                    // no logbook
                }
                break;

            case "T":
                // periode van 1 seconden tussen elke dag
                var milliseconds = 1000;
                for (int i = 0; i < skipDays; i++)
                {
                    Thread.Sleep(milliseconds);
                    Console.Clear();
                    day++;
                    terrarium.NextDay(ref arrTerrarium, ref logboek);
                    DrawTitelWithLine(day);
                    terrarium.Display(arrTerrarium);
                    if (logbookchoice == "simple")
                    {
                        terrarium.LogBook.Showlogboek();
                    }
                    else if (logbookchoice == "detailed")
                    {
                        Console.Write(terrarium.LogBook.ShowExtensiveLogboek(arrTerrarium));
                    }
                    else
                    {
                        // no logbook
                    }
                }
                break;

            default:
                Console.WriteLine("Wrong input");
                break;
            }
        }
예제 #4
0
 public Logboek(Terrarium terrarium)
 {
     this.Terrarium = terrarium;
 }