// 2.2 FELADAT public static void SelectLastMeasureTime(string city) { MetData lastMeasure = metData[0]; for (int i = metData.Count - 1; i >= 0; i--) { if (city == metData[i].City) { lastMeasure = metData[i]; break; } } Console.WriteLine($"Az utolsó mérési adat a megadott településről {lastMeasure.Time[0]}{lastMeasure.Time[1]}:{lastMeasure.Time[2]}{lastMeasure.Time[3]}-kor érkezett."); }
// 1. FELADAT public static void ImportData() { using (FileStream fs = new FileStream("tavirathu13.txt", FileMode.Open)) { using (StreamReader sr = new StreamReader(fs, Encoding.Default)) { while (!sr.EndOfStream) { string[] puffer = sr.ReadLine().Split(' '); var city = puffer[0]; var time = puffer[1]; var wind = puffer[2]; var temp = Convert.ToInt32(puffer[3]); MetData line = new MetData(city, time, wind, temp); metData.Add(line); } } } }
// 3. FELADAT public static void GetMaxMinTemp() { Console.WriteLine("\n3. feladat"); MetData maxTemp = metData[0]; MetData minTemp = metData[0]; foreach (var item in metData) { if (maxTemp.Temp < item.Temp) { maxTemp = item; } if (minTemp.Temp > item.Temp) { minTemp = item; } } Console.WriteLine($"A legalacsonyabb hőmérséklet: {minTemp.City} {minTemp.Time[0]}{minTemp.Time[1]}:{minTemp.Time[2]}{minTemp.Time[3]} {minTemp.Temp} fok."); Console.WriteLine($"A legmagasabb hőmérséklet: {maxTemp.City} {maxTemp.Time[0]}{maxTemp.Time[1]}:{maxTemp.Time[2]}{maxTemp.Time[3]} {maxTemp.Temp} fok."); }