static void Main(string[] args)
        {
            ListOfPlanets newPlanetsList = new ListOfPlanets();
            string        filePath       = @"C:\Users\Roland Strod\Samples";
            string        fileName       = @"planets.txt";
            string        fullpath       = Path.Combine(filePath, fileName);

            string[] planetsFromFile = File.ReadAllLines(fullpath);

            foreach (string line in planetsFromFile)
            {
                string [] tempArray  = line.Split(new char[] { '$' }, StringSplitOptions.RemoveEmptyEntries);
                string    planetName = tempArray[0];
                int       planetMass = int.Parse(tempArray[1]);
                Console.WriteLine(planetName);
                Console.WriteLine(planetMass);
                Console.WriteLine("----");


                newPlanetsList.AddPlanetToList(planetName, planetMass);
            }

            newPlanetsList.PrintPlanets();

            Console.WriteLine("What planet do you want to remowe?");
            string userInput = Console.ReadLine();

            newPlanetsList.FindAndRemove(userInput);

            newPlanetsList.PrintPlanets();
            newPlanetsList.CountPlanets();
        }
Exemple #2
0
        static void Main(string[] args)
        {
            string        filePath       = @"C:\Users\opilane\samples";
            string        fileName       = @"planet.txt";
            string        fullPath       = Path.Combine(filePath, fileName);
            ListOfPlanets newPlanetsList = new ListOfPlanets();

            string[] planetsFromFile = File.ReadAllLines(fullPath);

            foreach (string line in planetsFromFile)
            {
                string[] teampArray = line.Split(new char[] { '$' }, StringSplitOptions.RemoveEmptyEntries);
                string   planetName = teampArray[0];
                int      planetMass = int.Parse(teampArray[1]);
                Console.WriteLine(planetName);
                Console.WriteLine(planetMass);
                Console.WriteLine("----");

                newPlanetsList.AddPlanetToList(planetName, planetMass);
            }
            newPlanetsList.PrintPlanets();
        }