You are on page 1of 4

Muhammad Osama CSC-18F-076

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace task
{
public class vehicle
{
public string model;
public string color;
public string engine;
public string door;

public vehicle()
{

public vehicle(string x, string y, string z, string t)


{
model = x;
color = y;
engine = z;
door = t;

public virtual void calculateSpeed()


{
int x=0;
Console.WriteLine("Speed is = {0}",x);
}
}
public class bike : vehicle
{

public void start()


{
Console.WriteLine("Speed = 0");
}

public void stop()


{
Console.WriteLine("Speed < 0 ");
}

public void run()


{
Console.WriteLine("Bike is moving ");
}

public override void calculateSpeed()


{
Muhammad Osama CSC-18F-076

int x = 500;
Console.WriteLine("Speed is = {0}", x);
}

public class car : vehicle


{
public void start()
{
Console.WriteLine("Speed = 0");
}

public void stop()


{
Console.WriteLine("Speed < 0 ");
}

public void run()


{
Console.WriteLine("Car is moving ");
}

public override void calculateSpeed()


{
int x = 1000;
Console.WriteLine("Speed is = {0}", x);
}
}

class Program
{
static void Main(string[] args)
{
vehicle a = new vehicle("2011", "Yellow", "12121", "0");
vehicle b = new vehicle("2005", "Blue", "4231", "02");
bike c = new bike();
car d = new car();

Console.WriteLine("Enter alphabets for checking the vehicle detail &


operation \n \t m)BIKE \n \t n)CAR");
char z;
z =Convert.ToChar(Console.ReadLine());
switch(z)
{
case 'm':

Console.WriteLine(" BIKE");
Console.WriteLine("\t---------------------");
Console.WriteLine("Model= {0}", a.model);
Console.WriteLine("Color= {0}", a.color);
Console.WriteLine("Engine = {0}", a.engine);
Console.WriteLine("Door = {0}", a.door);
Console.WriteLine("start");
c.start();
Muhammad Osama CSC-18F-076

Console.WriteLine("run ");
c.run();
Console.WriteLine("stop");
c.stop();
Console.WriteLine("override");
c.calculateSpeed();
break;

case 'n':

Console.WriteLine(" CAR");
Console.WriteLine("-------------------------");
Console.WriteLine("Model= {0}", b.model);
Console.WriteLine("Color = {0}", b.color);
Console.WriteLine("Engine = {0}", b.engine);
Console.WriteLine("Door = {0}", b.door);
Console.WriteLine("start");
d.start();
Console.WriteLine(" run");
d.run();
Console.WriteLine("stop ");
d.stop();
Console.WriteLine(" override");
d.calculateSpeed();
break;

default:
Console.WriteLine("You pressed wrong value.");
break;
}

}
}
}
Muhammad Osama CSC-18F-076

You might also like