Пример #1
0
        public void Reading() //För att läsa in matcher
        {
            Contests.Clear();

            var path = @"C:\Users\emma\source\repos\InlamningsuppgiftOOAD\InlamningsuppgiftOOAD\Files\Contests.txt";

            var numberOfClients = 0;

            using (StreamReader r = new StreamReader(path))
            {
                string line;
                while ((line = r.ReadLine()) != null)
                {
                    numberOfClients++;
                }
            }

            using (var reader = new StreamReader(path)) //Textfil  läsas in
            {
                for (int i = 0; i < numberOfClients; i++)
                {
                    string information = reader.ReadLine();

                    string[] toArrays = information.Split(';');

                    Contest client = new Contest(toArrays[0], Convert.ToDateTime(toArrays[1]), Convert.ToDateTime(toArrays[2]), toArrays[3]);

                    Contests.Add(client);
                }

                if (numberOfClients == 0)
                {
                    Console.WriteLine("Inga matcher funna");
                }
            }
        }
Пример #2
0
 public bool RemoveContest(Contest contest)
 {
     Contests.Remove(contest);
     return(true);
 }
Пример #3
0
 public bool AddContest(Contest contest)
 {
     Contests.Add(contest);
     return(true);
 }