valasztas_esti/Valasztas2/Kepviselo.cs

52 lines
1.3 KiB
C#
Raw Normal View History

2023-04-04 17:09:00 +00:00
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
namespace Valasztas2
{
public class Kepviselo
{
public static List<Kepviselo> LoadFromTxt(string filename)
{
List<Kepviselo> lista = new List<Kepviselo>();
string[] sorok = File.ReadAllLines(filename);
foreach (var sor in sorok)
{
lista.Add(new Kepviselo(sor));
}
return lista;
}
private string _part;
public int Kerulet { get; set; }
public int Szavazat { get; set; }
public string VezetekNev { get; set; }
public string KeresztNev { get; set; }
public string Part {
get {
return _part;
}
set {
if (value == "-") _part = "független"; else _part = value;
}
}
public string TeljesNev {
get {
return VezetekNev + " " + KeresztNev;
}
}
public Kepviselo(string adat)
{
string[] adatok = adat.Split(' ');
Kerulet = int.Parse(adatok[0]);
Szavazat = int.Parse(adatok[1]);
VezetekNev = adatok[2];
KeresztNev = adatok[3];
Part = adatok[4];
}
}
}