1. Write a c# program contains “Car” as abstract class and an instance variable reg no, one concrete method openTank (), two abstract methods steering (int direction, int angle), braking (int force) and its implementation sub classes Tata, Mahindra which overlies above methods. Implement the above scenario and use all access specifiers
abstract class Car
{
public int Force { get; set; }
public int Direction { get; set; }
public int Angle { get; set; }
protected Car()
{
OpenTank();
}
public void OpenTank()
{
Console.WriteLine("Tank open");
}
public abstract void Move(int direction, int angle);
public abstract void Braking(int force);
}
class Tata : Car
{
public Tata() : base()
{
}
public override void Braking(int force)
{
Force -= force;
}
public override void Move(int direction, int angle)
{
Direction = direction;
Angle = angle;
}
}
class Mahindra : Car
{
public Mahindra() : base()
{
}
public override void Braking(int force)
{
Force -= force;
}
public override void Move(int direction, int angle)
{
Direction = direction;
Angle = angle;
}
}
static void Main()
{
Tata tata = new Tata();
Mahindra mahindra = new Mahindra();
Console.ReadKey();
}
Comments
Leave a comment