Exemplo n.º 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");
                }
            }
        }
Exemplo n.º 2
0
 public bool RemoveContest(Contest contest)
 {
     Contests.Remove(contest);
     return(true);
 }
Exemplo n.º 3
0
 public bool AddContest(Contest contest)
 {
     Contests.Add(contest);
     return(true);
 }