Advertisement
Guest User

Untitled

a guest
Oct 28th, 2016
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. class Car
  2. {
  3. string _plate = "";
  4.  
  5. public string Plate
  6. {
  7. get { return _plate; }
  8. set { _plate = value; }
  9. }
  10.  
  11. }
  12. class Ferrari : Car
  13. {
  14. string specialName = "";
  15.  
  16. public string SpecialName
  17. {
  18. get { return specialName; }
  19. set { specialName = value; }
  20. }
  21.  
  22. Ferrari (Car obj )
  23. {
  24. specialName = (obj is Ferrari) ? ((Ferrari)obj).SpecialName : "";
  25. }
  26. }
  27.  
  28. static void ManageCars (Car A)
  29. {
  30. if (A is Ferrari)
  31. {
  32. Ferrari B= (Ferrari) A;
  33. Console.Writeline("This is a Ferrari! specialName is " + B.SpecialName);
  34. }
  35. //else if(A is Mercedes)
  36. //{
  37. ...
  38. //}
  39. else
  40. {
  41. Console.Writeline("This is simple car");
  42. }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement