Browse Source

Dorabotka

ГаряевСА 1 tháng trước cách đây
mục cha
commit
36aaca52b5
1 tập tin đã thay đổi với 45 bổ sung13 xóa
  1. 45 13
      MyCalendarHome/MainWindow.axaml.cs

+ 45 - 13
MyCalendarHome/MainWindow.axaml.cs

@@ -55,7 +55,7 @@ namespace MyCalendarHome
             else if (f == 9) Animal = "Snake";
             else if (f == 10) Animal = "Horse";
             else if (f == 11) Animal = "Goat";
-            else if (f == 0) Animal = "Monkeq";
+            else if (f == 0) Animal = "Monkey";
             else if (f == 1) Animal = "Rooster";
             else if (f == 2) Animal = "Dog";
             else Animal = "Pig";
@@ -189,7 +189,7 @@ namespace MyCalendarHome
             }
         }
 
-        static void getData(string path, ref List<MyStruct> MS)
+        static void getData(string path, ref List<MyStructZodiac> MSZ, ref List<MyStructGoroskop> MSG)
         {
             using (StreamReader sr = new StreamReader(path))
             {
@@ -198,8 +198,8 @@ namespace MyCalendarHome
                     string[] array = sr.ReadLine().Split(';');
                     try
                     {
-                        DateTime data1 = new DateTime(Convert.ToInt32(array[2]), Convert.ToInt32(array[1]), Convert.ToInt32(array[0]));
-                        MS.Add(new MyStruct()
+                        DateTime data1 = new DateTime(1, Convert.ToInt32(array[1]), Convert.ToInt32(array[0]));
+                        MSZ.Add(new MyStructZodiac()
                         {
                             data = data1,
                             str = ""
@@ -208,12 +208,30 @@ namespace MyCalendarHome
                     catch (Exception e)
                     {
                         DateTime data = new DateTime();
-                        MS.Add(new MyStruct()
+                        MSZ.Add(new MyStructZodiac()
                         {
                             data = data,
                             str = e.Message
                         });
-                    }                  
+                    }
+                    try
+                    {
+                        DateTime data1 = new DateTime(Convert.ToInt32(array[2]), 1, 1);
+                        MSG.Add(new MyStructGoroskop()
+                        {
+                            data = data1,
+                            str = ""
+                        });
+                    }
+                    catch (Exception e)
+                    {
+                        DateTime data = new DateTime();
+                        MSG.Add(new MyStructGoroskop()
+                        {
+                            data = data,
+                            str = e.Message
+                        });
+                    }
                 }
             }
         }
@@ -227,25 +245,39 @@ namespace MyCalendarHome
                 }
             }
         }
-        struct MyStruct
+        struct MyStructZodiac
+        {
+            public DateTime data;
+            public string str;
+        }
+        struct MyStructGoroskop
         {
             public DateTime data;
             public string str;
         }
         private void WorkFile(object sender, RoutedEventArgs e)
         {
-            List<MyStruct> myStruct = new List<MyStruct>();
+            List<MyStructZodiac> myStructzodiac = new List<MyStructZodiac>();
+            List<MyStructGoroskop> myStructgoroskop = new List<MyStructGoroskop>();
             List<string> idonto = new List<string>();
-            getData("C:\\Users\\semen\\Downloads\\horoscopeEastern.csv", ref myStruct);
-            foreach (MyStruct item in myStruct)
+            getData("horoscopeEastern.csv", ref myStructzodiac, ref myStructgoroskop);
+            for (int i = 0; i < myStructzodiac.Count; i++)
             {
-                if (item.data == DateTime.MinValue)
+                if (myStructzodiac[i].data == DateTime.MinValue && myStructgoroskop[i].data == DateTime.MinValue)
+                {
+                    idonto.Add(i + " Error in zodiak: " + myStructzodiac[i].str + "\n"+ i + " Error in goroskop: " + myStructgoroskop[i].str);
+                }
+                else if (myStructzodiac[i].data == DateTime.MinValue && myStructgoroskop[i].data != DateTime.MinValue)
+                {
+                    idonto.Add(i + " Error in zodiak: " + myStructzodiac[i].str + "\n" + i + " Восточный гороскоп: " + AnimalYear(myStructgoroskop[i].data.Year));
+                }
+                else if (myStructzodiac[i].data != DateTime.MinValue && myStructgoroskop[i].data == DateTime.MinValue)
                 {
-                    idonto.Add(item.str);
+                    idonto.Add(i + " Знак зодиака: " + Zodiak(myStructzodiac[i].data.Day, myStructzodiac[i].data.Month) + "\n" + i + " Error in goroskop: " + myStructgoroskop[i].str);
                 }
                 else
                 {
-                    idonto.Add(Zodiak(item.data.Day, item.data.Month) + " " + AnimalYear(item.data.Year));
+                    idonto.Add(i + " Знак зодиака: " + Zodiak(myStructzodiac[i].data.Day, myStructzodiac[i].data.Month) + "\n" + i + " Восточный гороскоп: " + AnimalYear(myStructgoroskop[i].data.Year));
                 }
             }
             inputData("Input.txt", idonto);