Пример #1
0
        public void DrawTitelWithLine(int day)
        {
            var lineDrawer = new _LineDrawer();
            var dayTitel   = "DAY : " + day;

            Console.WriteLine(dayTitel);
            lineDrawer.DrawLine(dayTitel.Length, '*');
        }
Пример #2
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);
            }
        }
Пример #3
0
        public string ShowExtensiveLogboek(Organism[,] arrOrganisms)
        {
            int         counter    = 1;
            _LineDrawer LineDrawer = new _LineDrawer();

            ExtensiveLogboekBuilder  = string.Empty;
            ExtensiveLogboekBuilder += $"Terrarium {Terrarium.Name} on day {Terrarium.Day}: \n";
            var TitleLength = ExtensiveLogboekBuilder.Length;

            ExtensiveLogboekBuilder += $"{LineDrawer.DrawLine(TitleLength, '*')}{LineDrawer.DrawLine(TitleLength, '*')}";

            // for each organism, list its properties and actions
            // this way is not very good, you need to instead go through the array once, and collect all the information in a list or something. Then you go through the list and show it
            // for each group of organisms

            // plants

            ExtensiveLogboekBuilder += $"Plants:\nCurrent: {numberOfPlants}\tAdded: {CreatedPlants}\tEaten: {EatenPlants}\n{LineDrawer.DrawLine(TitleLength, '*')}";
            ExtensiveLogboekBuilder += "counter\tID\t\tPosition\tLife\n";

            foreach (Organism anOrganism in arrOrganisms)
            {
                if (anOrganism is Plant)
                {
                    ExtensiveLogboekBuilder += $"{counter}\t{anOrganism.ID}\t{anOrganism.Position}\t{anOrganism.Life}\n"; /* How will this work, will it call the ToString() method of the coordinate class? Will we get both x and y positions?
                                                                                                                           * It calls the ToString() method of the coordinate class yes!*/
                    counter++;
                }
            }
            ExtensiveLogboekBuilder += $"{LineDrawer.DrawLine(TitleLength, '*')}";
            counter = 1;
            // herbivores

            ExtensiveLogboekBuilder += $"Herbivores\nCurrent: {numberOfHerbivores}\tAdded: {BornHerbivores}\tEaten: {EatenHerbivores}\n{LineDrawer.DrawLine(TitleLength, '*')}";
            ExtensiveLogboekBuilder += "counter\tID\t\tPosition\tLife\tLast Move\n";

            foreach (Organism anOrganism in arrOrganisms)
            {
                if (anOrganism is Herbivore)
                {
                    ExtensiveLogboekBuilder += $"{counter}\t{anOrganism.ID}\t{anOrganism.Position}\t{anOrganism.Life}\t{anOrganism.LastMove}\n";
                    counter++;
                }
            }
            ExtensiveLogboekBuilder += $"{LineDrawer.DrawLine(TitleLength, '*')}";
            counter = 1;
            // Carnivores

            ExtensiveLogboekBuilder += $"Carnivores\nCurrent: {numberOfCarnivores}\tAdded: 0\tDied: {DiedCarnivores}\n{LineDrawer.DrawLine(TitleLength, '*')}";
            ExtensiveLogboekBuilder += "counter\tID\t\tPosition\tLife\tLast Move\n";

            foreach (Organism anOrganism in arrOrganisms)
            {
                if (anOrganism is Carnivore)
                {
                    ExtensiveLogboekBuilder += $"{counter}\t{anOrganism.ID}\t{anOrganism.Position}\t{anOrganism.Life}\t{anOrganism.LastMove}\n";
                    counter++;
                }
            }
            ExtensiveLogboekBuilder += $"{LineDrawer.DrawLine(TitleLength, '*')}{LineDrawer.DrawLine(TitleLength, '*')}";
            counter = 1;

            // humans

            ExtensiveLogboekBuilder += $"Humans\nCurrent: {numberOfHumans}\tAdded: 0\tDied: {DiedHumans}\n{LineDrawer.DrawLine(TitleLength, '*')}";
            ExtensiveLogboekBuilder += "counter\tID\t\tPosition\tLife\tLast Move\n";

            foreach (Organism anOrganism in arrOrganisms)
            {
                if (anOrganism is Human)
                {
                    ExtensiveLogboekBuilder += $"{counter}\t{anOrganism.ID}\t{anOrganism.Position}\t{anOrganism.Life}\t{anOrganism.LastMove}\n";
                    counter++;
                }
            }
            ExtensiveLogboekBuilder += $"{LineDrawer.DrawLine(TitleLength, '*')}{LineDrawer.DrawLine(TitleLength, '*')}";
            counter = 1;
            return(ExtensiveLogboekBuilder);
        }