Пример #1
0
        static void Add(List <MeteorologicalData> v)
        {
            MeteorologicalData New = new MeteorologicalData();

            try
            {
                Console.WriteLine("Enter City");
                New.City = Console.ReadLine();
                Console.WriteLine("Enter Atmospheric Pressure");
                New.AtmosphericPressure = (float)Convert.ToDouble(Console.ReadLine());
                Console.WriteLine("Enter Date");
                New.Date = DateTime.ParseExact(Console.ReadLine(), "dd.MM.yyyy", CultureInfo.InvariantCulture);
                Console.WriteLine("Enter Air Temperature");
                New.AirTemperature = (float)Convert.ToDouble(Console.ReadLine());
                Console.WriteLine("Enter Wind Speed");
                New.WindSpeed = (float)Convert.ToDouble(Console.ReadLine());
            }
            catch
            {
            }
            v.Add(New);
        }
Пример #2
0
        static void ChangeData(List <MeteorologicalData> v)
        {
            Console.WriteLine("Enter name to change");
            string name = Console.ReadLine();

            if ((v.FindIndex(f => f.City == name) != -1))
            {
                MeteorologicalData Change = v[v.FindIndex(f => f.City == name)];
                Console.WriteLine("1)City\n2)City\n3)Date\n4)Air Temperature\n5)Wind Speed ");
                var res = Console.ReadKey().KeyChar;
                Console.WriteLine("Enter new value");
                if (res == '1')
                {
                    Change.City = Console.ReadLine();
                }
                if (res == '2')
                {
                    Change.AtmosphericPressure = (float)Convert.ToDouble(Console.ReadLine());
                }
                if (res == '3')
                {
                    Change.Date = DateTime.ParseExact(Console.ReadLine(), "dd.MM.yyyy", CultureInfo.InvariantCulture);
                }
                if (res == '4')
                {
                    Change.AirTemperature = Convert.ToInt16(Console.ReadLine());
                }
                if (res == '5')
                {
                    Change.WindSpeed = Convert.ToInt16(Console.ReadLine());
                }
            }
            else
            {
                Console.WriteLine("Entered name not found");
                Console.ReadKey();
            }
        }
Пример #3
0
        public static List <MeteorologicalData> ReadDate(string path)
        {
            List <MeteorologicalData> g = new List <MeteorologicalData>();
            string text = "";

            try
            {
                using (StreamReader sr = new StreamReader(path))
                {
                    text = sr.ReadToEnd();
                }
                string[] Dates = text.Split('/');
                foreach (string s in Dates)
                {
                    string[] MetaDete = s.Split('|');
                    if (MetaDete.Length == 5)
                    {
                        MeteorologicalData d = new MeteorologicalData
                        {
                            City = MetaDete[0].Trim(),
                            AtmosphericPressure = (float)Convert.ToDouble(MetaDete[1]),
                            Date           = DateTime.ParseExact(MetaDete[2], "dd.MM.yyyy", CultureInfo.InvariantCulture),
                            AirTemperature = (float)Convert.ToDouble(MetaDete[3]),
                            WindSpeed      = Convert.ToInt32(MetaDete[4])
                        };
                        g.Add(d);
                    }
                }
            }
            catch
            {
                var flv = File.Create(path);
                flv.Close();
            }

            return(g);
        }
Пример #4
0
 public int CompareTo(MeteorologicalData p)
 {
     return(this.WindSpeed.CompareTo(p.WindSpeed));
 }