Advertisement
Guest User

Untitled

a guest
Nov 18th, 2019
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.28 KB | None | 0 0
  1. using System;
  2. public abstract class Car
  3. {
  4. Engine _newEngine;
  5.  
  6. public Car (Engine engine_1)
  7. {
  8.     _newEngine = engine_1;
  9. }
  10. public abstract void Go(); 
  11.  
  12. public void FixEngine (Garage g)
  13. {
  14.     g.fixMyEngine (Engine newEn);
  15. }
  16. }
  17.  
  18.  
  19. public class SportCar:Car
  20. {
  21. int _horsePower;
  22. public SportCar(Engine engine, int horsePower) : base(engine)
  23. {
  24. _horsePower = horsePower;
  25. }
  26. public override void Go()
  27. {
  28. Console.WriteLine("Driving in {}"+_horsePower );
  29. }
  30. }
  31.  
  32. public abstract class Engine
  33. {
  34.     float _size;
  35.     bool _working;
  36.     string _name;
  37.    
  38. public Engine( float size, string name)
  39. {
  40.      _size = size;
  41.     _name = name;
  42. }
  43. }
  44.  
  45. public class SportEngine:Engine
  46. {
  47. float _celinder;
  48.  
  49. public SportEngine(float size, string name, float celinder) : base (size, name)
  50. {
  51. _celinder = celinder;
  52. }
  53. }
  54. public class SlowEngine:Engine
  55. {
  56. float _minSpeed;
  57.  
  58. public SlowEngine(float size, string name, float minSpeed) : base (size, name)
  59. {
  60. _minSpeed = minSpeed;
  61. }
  62. }
  63.  
  64. public class Garage
  65. {
  66. public void fixMyEngine(Engine x)
  67. {
  68.     Console.WriteLine(x);
  69.  
  70. }
  71. }
  72.  
  73. public class Parking
  74. {
  75.     Car [] _cars;
  76.    public  Parking(Car [] arr)
  77.    {
  78.       _cars =   arr;
  79.    }
  80. }
  81.  
  82.  
  83.                    
  84. public class Program
  85. {
  86.     public static void Main()
  87.     {
  88.         SportCar a = new SportCar(2,"sds", 5, 18);
  89.        
  90.        
  91.     }
  92. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement