Advertisement
Guest User

Untitled

a guest
May 29th, 2015
266
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.57 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5.  
  6. namespace Pawel
  7. {
  8. public abstract class Plyta
  9. {
  10. public string autor;
  11. public string tytul;
  12. public double cena;
  13. public Plyta(string a, string t, double c)
  14. {
  15. this.autor = a;
  16. this.tytul=t;
  17. this.cena=c;
  18. }
  19.  
  20. public virtual void Opis()
  21. {
  22. }
  23.  
  24. public class CD : Plyta
  25. {
  26. public CD(string a, string t, double c)
  27. : base(a, t, c)
  28. {
  29.  
  30. }
  31. public override void Opis()
  32. {
  33. System.Console.WriteLine(autor + " nagral plyte o tytule: " + tytul + ", która kosztuje " + cena + " zl");
  34. }
  35.  
  36. }
  37.  
  38. public class DVD : Plyta
  39. {
  40. int rok;
  41. public DVD(string a, string t, double c, int r)
  42. : base(a, t, c)
  43. {
  44. this.rok = r;
  45. }
  46.  
  47. public override void Opis()
  48. {
  49. System.Console.WriteLine(autor + " jest rezyserem filmu " + tytul + ", ktory kosztuje " + cena + " i został nagrany w roku " + rok);
  50. }
  51.  
  52. }
  53.  
  54. static void Main(string[] args)
  55. {
  56. CD kompakt = new CD("Paweł Puzio","Puzon - Greatests Hits", 29);
  57. DVD film = new DVD("Nikodem Jedynak","YYYGGH",13,1945);
  58. kompakt.Opis();
  59. film.Opis();
  60. Console.ReadLine();
  61. }
  62. }
  63.  
  64. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement