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 ConsoleApp24
- {
- class Program
- {
- static void Main(string[] args)
- {
- Bus bus = new Bus();
- Tracktor tracktor = new Tracktor();
- Auto auto = new Auto();
- bus.Beep();
- tracktor.Beep();
- auto.Beep();
- }
- }
- public abstract class Vehicle
- {
- public string name;
- public virtual void Beep()
- {
- Console.WriteLine("Claxon");
- }
- }
- public class Bus : Vehicle
- {
- public override void Beep()
- {
- Console.WriteLine("Booooop");
- }
- }
- class Tracktor : Vehicle
- {
- public override void Beep()
- {
- Console.WriteLine("Bup");
- }
- }
- class Auto : Vehicle
- {
- public override void Beep()
- {
- base.Beep();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment