Ejemplo n.º 1
0
        public void Save()
        {
            List <string> output = new List <string>();

            output.AddRange(SeedHarvester.Export());
            output.AddRange(Composter.Export());
            output.AddRange(EggGatherer.Export());
            output.AddRange(MeatProcessor.Export());
            output.AddRange(FeatherGatherer.Export());

            Facilities.ForEach(fac => output.Add(fac.Export()));

            FileHandler.SaveData(output);
        }
Ejemplo n.º 2
0
        public Farm()
        {
            FileHandler     = new FileHandler();
            SeedHarvester   = new SeedHarvester(FileHandler);
            Composter       = new Composter(FileHandler);
            MeatProcessor   = new MeatProcessor(FileHandler);
            FeatherGatherer = new FeatherGatherer(FileHandler);
            EggGatherer     = new EggGatherer(FileHandler);

            FileHandler.Facilities.ForEach(fac =>
            {
                IFacility newFacility = null;
                string[] facilityData = fac.Split(":");
                string type           = facilityData[0];
                string name           = facilityData[1];
                string data           = facilityData[2];

                switch (type)
                {
                case "Chicken House":
                    newFacility = new ChickenHouse(name, data);
                    break;

                case "Duck House":
                    newFacility = new DuckHouse(name, data);
                    break;

                case "Grazing Field":
                    newFacility = new GrazingField(name, data);
                    break;

                case "Plowed Field":
                    newFacility = new PlowedField(name, data);
                    break;

                case "Natural Field":
                    newFacility = new NaturalField(name, data);
                    break;

                default:
                    throw new Exception("Invalid data");
                }
                Facilities.Add(newFacility);
            });
        }