Example #1
0
        public CanTheyMeet()
        {
            InitializeComponent();
           
         
            int lineCount = File.ReadLines("good").Count();
            LoadingScreen l = new LoadingScreen();
            l.Visible = true;
            result.Visible = false;
            l.InitProgressBar(lineCount);
            FillData(l);
            data.Close();
            data.Dispose();
            StreamWriter sw = new StreamWriter("stats");
            sw.WriteLine("Total number of persons : " + people.Count);
            int bothNull = 0;
            int birthNull = 0;
            for (int i = 0; i < people.Count; i++)
            {
                if (people[i].Birth.Year == 0 && people[i].Death.Year == 0)
                {
                    bothNull++;
                    continue;
                }
                if (people[i].Birth.Year == 0)
                {
                    birthNull++;
                }

            }
            sw.WriteLine("Both dates are nulls : " + bothNull);
            sw.WriteLine("Just Birth date is null : " + birthNull);
            sw.Flush();
            sw.Dispose();
        }
Example #2
0
 private void FillData(LoadingScreen l)
 { 
     string line;
     int i = 0;
     while ((line = data.ReadLine()) != null)
     {
         Person p = new Person(); ;
         p.Name = line.Split('=')[1];
         p.Birth = new Date(data.ReadLine().Split('=')[1]);
         p.Death = new Date(data.ReadLine().Split('=')[1]);
         people.Add(p);
         i += 3;
         l.SetProgress(i);
     }
     l.Dispose();
 
 }