Answer to Question #286278 in C# for Rose

Question #286278

create Circle and Triangle class by inheriting the Shape Class. Both the inherited classes




should override the WhoamI() method of the Shape Class.

1
Expert's answer
2022-01-10T07:38:18-0500
public class Shape


{


private void WhoamI()


{


Console.WriteLine("I m Shape");


}


}


class Triangle : public Shape


{


public virtual void WhoamI()


{


Console.WriteLine("I m Triangle");


}


}


public class Circle : public Shape


{


void WhoamI()


{


Console.WriteLine("I m Circle");


}


}


class Program


{


static void Main(string[] args)


{


Shape s;


s = new Triangle();


s.WhoamI();


s = new Circle();


s.WhoamI();


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
APPROVED BY CLIENTS