AlexRaynor

5.4

Oct 28th, 2019
180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.04 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace ConsoleApp24
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             Bus bus = new Bus();
  14.             Tracktor tracktor = new Tracktor();
  15.             Auto auto = new Auto();
  16.             bus.Beep();
  17.             tracktor.Beep();
  18.             auto.Beep();
  19.  
  20.  
  21.         }
  22.     }
  23.  
  24.  
  25.   public abstract class Vehicle
  26.     {
  27.         public string name;
  28.  
  29.         public virtual void Beep()
  30.         {
  31.             Console.WriteLine("Claxon");
  32.  
  33.         }
  34.  
  35.     }
  36.  
  37.     public class Bus : Vehicle
  38.     {
  39.         public override void Beep()
  40.         {
  41.             Console.WriteLine("Booooop");
  42.         }
  43.     }
  44.     class Tracktor : Vehicle
  45.     {
  46.         public override void Beep()
  47.         {
  48.             Console.WriteLine("Bup");
  49.         }
  50.     }
  51.     class Auto : Vehicle
  52.     {
  53.         public override void Beep()
  54.         {
  55.             base.Beep();
  56.         }
  57.  
  58.     }
  59. }
Advertisement
Add Comment
Please, Sign In to add comment