Answer to Question #329744 in C# for madhu

Question #329744

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

1
Expert's answer
2022-04-17T13:53:59-0400
    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();
    }

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS