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;
- namespace KolokwiumL3
- {
- public class Osoba
- {
- public string Imie { get; set; }
- public string Nazwisko { get; set; }
- public Osoba(string Imie, string Nazwisko)
- {
- this.Imie = Imie;
- this.Nazwisko = Nazwisko;
- }
- }
- public class Samochod
- {
- public string Marka { get; set; }
- public int RokProdukcji { get; set; }
- public bool Dostepnosc { get; set; }
- public Osoba Wlasciciel { get; set; }
- public Samochod()
- {
- this.Wlasciciel = new Osoba(null, null);
- }
- public Samochod(string Marka, int RokProdukcji)
- {
- this.Marka = Marka;
- this.RokProdukcji = RokProdukcji;
- this.Wlasciciel = new Osoba(null, null);
- this.Dostepnosc = true;
- }
- public string CzyDostepny()
- {
- if (Dostepnosc == false)
- {
- return string.Format("Sprzedany");
- }
- else
- {
- return string.Format("Dostepny");
- }
- }
- public void Sprzedaj(string Imie, string Nazwisko)
- {
- this.Wlasciciel = new Osoba(Imie, Nazwisko);
- this.Dostepnosc = false;
- }
- public string InfoSamochod()
- {
- if (Dostepnosc == false)
- {
- return string.Format("Samochod marki {0} rok produkcji {1}, jest {2} panu/pani {3} {4}", Marka, RokProdukcji, CzyDostepny(), Wlasciciel.Imie, Wlasciciel.Nazwisko);
- }
- else
- {
- return string.Format("Samochod marki {0} rok produkcji {1}, jest {2}", Marka, RokProdukcji, CzyDostepny());
- }
- }
- }
- class Program
- {
- static void Main(string[] args)
- {
- Samochod samochod = new Samochod("Opel",2018);
- Console.WriteLine(samochod.InfoSamochod());
- Console.WriteLine(samochod.Sprzedaj("Krystian","Mlynek"));
- Console.WriteLine(samochod.InfoSamochod());
- Console.ReadKey();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement