示例#1
0
        public static void ReportUntestedSeedsInStorage()
        {
            var plantCalculator = new PlantCalculator();

            var outFile       = File.CreateText("untested_seeds.txt");
            var untestedSeeds = plantCalculator.GetSeedsOfUntestedPlants();

            untestedSeeds.ToList()
            .ForEach(x => outFile.WriteLine(
                         $"{x.Flower.ToString()} {x.Stem.ToString()} " +
                         $"{x.Position?.ToString()}"));
            outFile.Flush();
            outFile.Close();
        }
示例#2
0
        public static void ReportUntestedPlantFormulasForCurrentPlants(IEnumerable <Plant> currentPlants)
        {
            var plantCalculator  = new PlantCalculator();
            var untestedFormulas = plantCalculator.GetUntestedPlantFormulasForCurrentPlants(currentPlants)
                                   .OrderBy(x => x.PlantA.Flower)
                                   .ThenBy(x => x.PlantA.Stem)
                                   .ThenBy(x => x.PlantB.Flower)
                                   .ThenBy(x => x.PlantB.Stem);

            var outFileFull = File.CreateText("formulasFull.txt");

            untestedFormulas.ToList()
            .ForEach(x => outFileFull.WriteLine(
                         $"{x.PlantA.Flower.ToString()} {x.PlantA.Stem.ToString()} " +
                         $"+ {x.PlantB.Flower.ToString()} {x.PlantB.Stem.ToString()} " +
                         $"= {x.Result.Flower.ToString()} {x.Result.Stem.ToString()}"));
            outFileFull.Flush();
            outFileFull.Close();

            var outFile          = File.CreateText("formulas.txt");
            var filteredFormulas = plantCalculator.FilterPlantFormulasOnlyBetweenCurrentPlants(currentPlants, untestedFormulas);

            filteredFormulas.ToList()
            .ForEach(x => outFile.WriteLine(
                         $"{x.PlantA.Flower.ToString()} {x.PlantA.Stem.ToString()} " +
                         $"+ {x.PlantB.Flower.ToString()} {x.PlantB.Stem.ToString()} " +
                         $"= {x.Result.Flower.ToString()} {x.Result.Stem.ToString()}"));
            outFile.Flush();
            outFile.Close();

            var outFileResults = File.CreateText("results.txt");
            var results        = untestedFormulas.Select(x => x.Result).ToList().Distinct(new PlantComparer())
                                 .OrderBy(x => x.Flower)
                                 .ThenBy(x => x.Stem);

            outFileResults.WriteLine($"Results count: {results.Count()}\n");
            outFileResults.WriteLine($"----------------------------------------------\n");
            results.ToList()
            .ForEach(x => outFileResults.WriteLine(
                         $"{x.Flower.ToString()} {x.Stem.ToString()}"));
            outFileResults.Flush();
            outFileResults.Close();
        }
示例#3
0
        public static void ReportFormulasForMissingResults()
        {
            var missingResults = new List <Plant>
            {
                new Plant(FlowerType.Baccatus, StemType.Reptans),
                new Plant(FlowerType.Baccatus, StemType.Scandens),
                new Plant(FlowerType.Lilia, StemType.Reptans),
                new Plant(FlowerType.Tahitian, StemType.Reptans),
                new Plant(FlowerType.Tilia, StemType.Reptans),
                new Plant(FlowerType.Tilia, StemType.Scandens),
                new Plant(FlowerType.Venus, StemType.Reptans),
                new Plant(FlowerType.Spotted, StemType.Glaber),
                new Plant(FlowerType.Spotted, StemType.Multiflora),
                new Plant(FlowerType.Spotted, StemType.Pitcher),
                new Plant(FlowerType.Spotted, StemType.Ridgeball),
                new Plant(FlowerType.Spotted, StemType.TigerFern),
                new Plant(FlowerType.Spotted, StemType.Weeper),
            };

            var formulas = new Dictionary <Plant, IEnumerable <PlantFormula> >();

            var plantCalculator = new PlantCalculator();

            missingResults.ForEach(x => formulas.Add(x, plantCalculator.GetFormulasWithResult(x)));

            var outFile = File.CreateText("missing.txt");

            outFile.WriteLine($"Missing plants count: {missingResults.Count()}\n");

            formulas.ToList()
            .ForEach(x =>
            {
                outFile.WriteLine($"----------------------------------------------\n");
                outFile.WriteLine($"{x.Key.Flower.ToString()} {x.Key.Stem.ToString()}\n");
                x.Value.ToList().ForEach(y => outFile.WriteLine($"{y.PlantA.Flower.ToString()} {y.PlantA.Stem.ToString()} x {y.PlantB.Flower.ToString()} {y.PlantB.Stem.ToString()}"));
            });

            outFile.Flush();
            outFile.Close();
        }
示例#4
0
        public static void ReportUntestedPlants()
        {
            var plantCalculator = new PlantCalculator();

            var outFile        = File.CreateText("untested_plants.txt");
            var untestedPlants = plantCalculator.GetUntestedPlants();

            outFile.WriteLine($"Untested plants count: {untestedPlants.Count()}\n");

            var lastFlower = (FlowerType)1;

            untestedPlants.ToList()
            .ForEach(x =>
            {
                if (x.Flower != lastFlower)
                {
                    outFile.WriteLine($"----------------");
                }
                lastFlower = x.Flower;
                outFile.WriteLine($"{x.Flower.ToString()} {x.Stem.ToString()}");
            });

            outFile.WriteLine($"\n----------------------------------------------\n");

            var lastStem = (StemType)1;

            untestedPlants.OrderBy(x => x.Stem).ThenBy(x => x.Flower).ToList()
            .ForEach(x =>
            {
                if (x.Stem != lastStem)
                {
                    outFile.WriteLine($"----------------");
                }
                lastStem = x.Stem;
                outFile.WriteLine($"{x.Flower.ToString()} {x.Stem.ToString()}");
            });

            outFile.Flush();
            outFile.Close();
        }