Example #1
0
        public void UlozSoubor(string soubor, Osoba[] osoby)
        {
            using (StreamWriter sw = new StreamWriter(File.Open(soubor, FileMode.Create, FileAccess.Write)))
            {
                sw.WriteLine("Počet osob:" + osoby.Length);

                foreach (Osoba item in osoby)
                {
                    sw.WriteLine("{0};{1};{2};{3}", item.jmeno, item.vek, item.pohl, item.datum.Ticks);
                   //sw.WriteLine(item.ToString(CultureInfo.InvariantCulture));
                }
            }
        }
Example #2
0
        private static Osoba NactiOsobu()
        {
            Console.Write("Zadejte jméno a příjmení: ");
            String jmeno = Console.ReadLine();

            Console.Write("Zadejte věk: ");
            byte vek = Convert.ToByte(Console.ReadLine());

            Console.Write("Zadejte pohlavi (muz X zena): ");
            pohlavi pohl;

            if (Console.ReadLine() == "muz")
                pohl = pohlavi.muz;
            else
                pohl = pohlavi.zena;

            Osoba os1 = new Osoba(jmeno, vek, pohl, DateTime.UtcNow);

            return os1;
        }
Example #3
0
        public Osoba[] NactiSoubor(string soubor)
        {
            using (StreamReader sr = new StreamReader(File.OpenRead(soubor)))
            {
                int index = 0;
                if (!sr.EndOfStream)
                {
                    string radek = sr.ReadLine();
                    string[] texty = radek.Split(':');
                    int pocet = int.Parse(texty[1]);
                    Array.Resize(ref pole, pocet);

                }
                while (!sr.EndOfStream)
                {

                    string radek = sr.ReadLine();
                    string[] texty = radek.Split(';');

                    string jmeno = texty[0];
                    byte vek = Convert.ToByte(texty[1]);
                    pohlavi pohl;

                    if (texty[2] == "muz")
                        pohl = pohlavi.muz;
                    else
                        pohl = pohlavi.zena;

                    DateTime datum = new DateTime(long.Parse(texty[3]));

                    Osoba os = new Osoba(jmeno, vek, pohl, datum);
                    pole[index] = os;
                    index++;
                }
            }
            return pole;
        }
Example #4
0
 public void PridejUloz(Osoba osoba)
 {
     Array.Resize(ref pole, pole.Length + 1);
     pole[pole.Length -1] = osoba;
     Uloz();
 }