Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace ConsoleApp12
- {
- /*
- class Program
- {
- static void Main(string[] args)
- {
- Knight spk = new Knight();
- spk.doTask();
- spk.lives--;
- Console.WriteLine("Lives: " + spk.lives);
- spk.task = new SavePrincessTask();
- spk.doTask();
- Console.WriteLine("Lives: " + spk.lives);
- Console.ReadKey();
- }
- }
- abstract class Task
- {
- public abstract void challengeAccepted();
- }
- class Knight
- {
- public Task task = new SeatInToiletTask();
- public int lives = 3;
- public void doTask()
- {
- task.challengeAccepted();
- }
- }
- class SavePrincessTask : Task
- {
- public override void challengeAccepted()
- {
- Console.WriteLine("Jestem Shrek i uratuje ksiezniczke!");
- }
- }
- class SeatInToiletTask : Task
- {
- public override void challengeAccepted()
- {
- Console.WriteLine("Jestem strachliwym rycerzem...siedze w kiblu i udaje ze mam raczke!");
- }
- }
- */
- class Program
- {
- static void Main(string[] args)
- {
- Car car_1 = new Car();
- car_1.engine = new ElectriceEngine();
- car_1.startEngine();
- Console.ReadKey();
- }
- }
- abstract class Vehicle
- {
- }
- class Car : Vehicle
- {
- public Engine engine;
- public void startEngine()
- {
- engine.start();
- }
- public void stopEngine()
- {
- engine.stop();
- }
- }
- abstract class Engine
- {
- public bool working = false;
- public abstract void start();
- public abstract void stop();
- }
- class ElectriceEngine : Engine
- {
- public override void start()
- {
- working = true;
- Console.WriteLine("bezglosnie sie odpalam");
- }
- public override void stop()
- {
- working = false;
- Console.WriteLine("Bezglosnie sie wylaczam");
- }
- }
- class BenzineEngine : Engine
- {
- public override void start()
- {
- working = true;
- Console.WriteLine("Glosno sie odpalam");
- }
- public override void stop()
- {
- working = false;
- Console.WriteLine("Glosno sie wylaczam");
- }
- }
- class DieselEngine : Engine
- {
- public override void start()
- {
- working = true;
- Console.WriteLine("Dymie kiedy sie odpalam");
- }
- public override void stop()
- {
- working = false;
- Console.WriteLine("Dymie kiedy sie wylaczam");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement