Download the solution template file (Quiz4_template.zip) from the Quiz content folder. Unzip the template to a folder on your local file system and open the solution file with Visual Studio 2010.

Perform the following:

  • Create an Interface called IDisplayShapeInfo that specifies the following methods:
    • DisplayShapeStatistics with return type String
    • DisplayArea with return type String
  • Create an Interface called ICalculateVertices that specifies the following methods:
    • TotalVertices with return type int
    • TotalSides with a return type of int
  • Have the GeometricFigure class implement the IDisplayShapeInfo interface:
    • DisplayShapeStatistics will display current object type (use GetType) and the current object area (use the Area function that you wrote).
    • DisplayArea like above but only display the area.
  • Finish the Rectangle, Square and Triangle classes:
    • Add properties Height and Width with proper {get; set;}.
    • Finish the constructors for these classes to allow us to set height and width at instantiation time.
    • Uncomment the code in the ComputeArea functions for each class.
  • Have the Rectangle and Triangle classes implement the ICalculateVertices interface:
    • TotalVertices will return 3 for Triangle and 4 for Rectangle;
    • TotalSides will also return 3 for Triangle and 4 for Rectangle;
  • Have the Rectangle and Triangle classes override with their own version of the IDisplayShapeInfo method:
    • DisplayShapeStatistics will display current object type, area, height, width, vertices and sides.
  • Have the Square class override with its own version of the IDisplayShapeInfo method:
    • DisplayShapeStatistics will display current object type, area side length, vertices and sides.
  • Create a new class called Circle that inherits from GeometricFigure with the following:
    • A Radius float property with proper {get; set;}
    • A constructor method that allows Radius as an argument.
    • A ComputeArea method that uses Math.PI to compute the area based on Radius.
    • Override DisplayShapeStatistics to display object type, area and radius.
  • In the Program.Main method:
    • Instantiate a Triangle, Square, Rectangle and Circle.
    • Use Console.Writeline to show DisplayShapeStatistics for each.
Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.