Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.IO;
- namespace ConsoleApplication1
- {
- class Osoba
- {
- private string imie;
- private string nazwisko;
- private int data;
- public Osoba(string i,string y, int x)
- {
- imie = i;
- nazwisko = y;
- data = x;
- }
- public void wyswietl()
- {
- Console.WriteLine("Imie: {0}\nNazwisko: {1}\nData ur.: {2}",imie,nazwisko,data);
- }
- public void zapisz()
- {
- string nazwa = string.Format("{0}{1}.txt", imie, nazwisko);
- TextWriter tw = new StreamWriter(nazwa);
- tw.WriteLine("Imie: {0}", imie);
- tw.WriteLine("Nazwisko: {0}", nazwisko);
- tw.WriteLine("Data: {0}", data);
- tw.Close();
- }
- }
- class Program
- {
- static void Main(string[] args)
- {
- try
- {
- string i, y;
- int x;
- Console.WriteLine("Podaj imie");
- i = Console.ReadLine();
- Console.WriteLine("Podaj nazwisko");
- y = Console.ReadLine();
- Console.WriteLine("Podaj date");
- x = Convert.ToInt32(Console.ReadLine());
- Osoba lol = new Osoba(i, y, x);
- lol.wyswietl();
- lol.zapisz();
- }
- catch (Exception)
- {
- Console.WriteLine("Blad");
- }
- Console.ReadLine();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement