Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- public abstract class Car
- {
- Engine _newEngine;
- public Car (Engine engine_1)
- {
- _newEngine = engine_1;
- }
- public abstract void Go();
- public void FixEngine (Garage g)
- {
- g.fixMyEngine (Engine newEn);
- }
- }
- public class SportCar:Car
- {
- int _horsePower;
- public SportCar(Engine engine, int horsePower) : base(engine)
- {
- _horsePower = horsePower;
- }
- public override void Go()
- {
- Console.WriteLine("Driving in {}"+_horsePower );
- }
- }
- public abstract class Engine
- {
- float _size;
- bool _working;
- string _name;
- public Engine( float size, string name)
- {
- _size = size;
- _name = name;
- }
- }
- public class SportEngine:Engine
- {
- float _celinder;
- public SportEngine(float size, string name, float celinder) : base (size, name)
- {
- _celinder = celinder;
- }
- }
- public class SlowEngine:Engine
- {
- float _minSpeed;
- public SlowEngine(float size, string name, float minSpeed) : base (size, name)
- {
- _minSpeed = minSpeed;
- }
- }
- public class Garage
- {
- public void fixMyEngine(Engine x)
- {
- Console.WriteLine(x);
- }
- }
- public class Parking
- {
- Car [] _cars;
- public Parking(Car [] arr)
- {
- _cars = arr;
- }
- }
- public class Program
- {
- public static void Main()
- {
- SportCar a = new SportCar(2,"sds", 5, 18);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement