123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace _06_3_Dekorator_Interfejsy
- {
- public interface ISamochod
- {
- string PodajNazwe();
- double PodajCene();
- }
- public class Ford : ISamochod
- {
- public string PodajNazwe()
- {
- return "Ford";
- }
- public double PodajCene()
- {
- return 50000;
- }
- }
- public class Peugot : ISamochod
- {
- public string PodajNazwe()
- {
- return "Peugot";
- }
- public double PodajCene()
- {
- return 60000;
- }
- }
- public interface IDekorator : ISamochod
- {
- ISamochod pojazd { get; set; }
- }
- public class Klima : IDekorator
- {
- public ISamochod pojazd { get; set; }
- public Klima(ISamochod aPojazd)
- {
- pojazd = aPojazd;
- }
- public string PodajNazwe()
- {
- return pojazd.PodajNazwe() + " z klimatyzacją";
- }
- public double PodajCene()
- {
- return pojazd.PodajCene() + 7000;
- }
- }
- public class Metalik : IDekorator
- {
- public ISamochod pojazd { get; set; }
- public Metalik(ISamochod aPojazd)
- {
- pojazd = aPojazd;
- }
- public string PodajNazwe()
- {
- return pojazd.PodajNazwe() + " z lakierem metalic";
- }
- public double PodajCene()
- {
- return pojazd.PodajCene() + 2000;
- }
- }
- public class Zimowki : IDekorator
- {
- public ISamochod pojazd { get; set; }
- public Zimowki(ISamochod aPojazd)
- {
- pojazd = aPojazd;
- }
- public string PodajNazwe()
- {
- return pojazd.PodajNazwe() + " z kompletem opon zimowych";
- }
- public double PodajCene()
- {
- return pojazd.PodajCene() + 1500;
- }
-
- }
- }
|