Question
C# Create an abstract class called Shape. Add two properties to the class, a string Name and an int Sides. Make both properties read/write and
C#
Create an abstract class called Shape. Add two properties to the class, a string Name and an int Sides. Make both properties read/write and not abstract. Create a constructor that takes two arguments: a string name and an int sides. Assign the parameter values to the property values. Create a virtual method called Draw (string return type) and an abstract method called Area that has a return type of double. For the Draw method simply return a string that reports "now drawing "+ Name.
Then
Create a derived class called Triangle that is derived from Shape. Add two properties to the Triangle class called TBase and THeight. Both properties should be of double data type. Make both properties read/write. Create a parameterized constructor that requires two double values to be passed in as arguments (double tBase, double tHeight). Make sure and call the base class constructor explicitly, passing the literal values: "Triangle" and 3. In the constructor, assign the properties the values passed in as parameters. Implement the Area method so that it returns .5 * TBase * THeight.
Last
Create a derived class called Circle that derives from Shape. Add a read/write property of data type double called Radius. The class should have a constructor that requires three parameters (double radius, string name, int sides). Make sure and call the base class constructor explicitly and pass along the name and sides arguments. In the constructor, assign the value of radius to its corresponding property. Implement the Area method to return a double with an implementation that looks like the following: return Math.PI* Math.Sqrt(Radius).
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started