Ejemplo n.º 1
0
        public WaterTerrarium CreateWaTerrarium(List <WaterTerrarium> waTerList)
        {
            string         id        = util.IdGenerator();
            List <Snake>   snakeList = new List <Snake>();
            WaterTerrarium lanTer    = new WaterTerrarium(id, snakeList); //PROBLEM maybe change LandTerrarium to just Terrarium?

            return(lanTer);
        }
Ejemplo n.º 2
0
 public void AddTerToList(WaterTerrarium waTer, List <WaterTerrarium> waTerList) //CHANGED LandTerrarium -> Terrarium
 {
     waTerList.Add(waTer);
 }
Ejemplo n.º 3
0
        public static void Main(string[] args)
        {
            XML       theXml    = new XML();
            Utility   util      = new Utility();
            SnakeMenu snakeMenu = new SnakeMenu();

            List <Snake>          snakeList  = new List <Snake>();
            List <WaterTerrarium> waTerList  = new List <WaterTerrarium>();
            List <LandTerrarium>  lanTerList = new List <LandTerrarium>();
            LandTerrarium         laTer;
            WaterTerrarium        waTer;

            string terFilename   = "LandTerrarium.xml";
            string waterFilename = "WaterTerrarium.xml";
            string snakeFilename = "JustSnakes.xml";


            if (!File.Exists("LandTerrarium.xml") || theXml.IsEmpty(terFilename))
            {
                laTer = new LandTerrarium(util.IdGenerator(), snakeList);
                lanTerList.Add(laTer);
                theXml.LandTerWriteToXmlFile(lanTerList, terFilename);
            }

            if (!File.Exists("JustSnakes.xml") || theXml.IsEmpty(snakeFilename))
            {
                Console.WriteLine("Please create a Snake first!"); //snake already exists

                snakeMenu.CreateSnake(snakeList);
            }

            if (!File.Exists("WaterTerrarium.xml") || theXml.IsEmpty(waterFilename))
            {
                waTer = new WaterTerrarium(util.IdGenerator(), snakeList);
                waTerList.Add(waTer);
                theXml.WaterTerWriteToXmlFile(waTerList, waterFilename);
            }

            snakeList  = theXml.LoadObjectFromXmlFile(snakeFilename);
            waTerList  = theXml.WaterTerLoadObjectFromXmlFile(waterFilename);
            lanTerList = theXml.LandTerLoadObjectFromXmlFile(terFilename);


            theXml.WriteToXmlFile(snakeList, snakeFilename);

            Menu mainMenu = new Menu();

            do
            {
                mainMenu.DisplayMainMenu();
                string choice = mainMenu.InputHandler("Type option with lowercase: ");
                if (mainMenu.Switch(choice, snakeList, lanTerList, waTerList, snakeFilename, terFilename, waterFilename))
                {
                    theXml.WaterTerWriteToXmlFile(waTerList, waterFilename);
                    theXml.LandTerWriteToXmlFile(lanTerList, terFilename);
                    theXml.WriteToXmlFile(snakeList, snakeFilename);
                }
                else
                {
                    break;
                }
            } while (true);
        }