Jump to content

Help with C#

SickSix66

Hey guys, I need help with my assignment in C# 

Pictures attached are the question.

post-83698-0-65830700-1416202385.jpg

post-83698-0-83366800-1416202386.jpg

Link to comment
Share on other sites

Link to post
Share on other sites

Post the code you've written so far and what your problems are. We're here to help, not to write code for you :)

 

Also be sure to use code tags whenever posting code to the forum. You can do this with the blue < > symbol above the text box you write your replies in, or manually inside code like so

[code]// Put your code between the code tagspublic class Example{    ...}[/code]
Link to comment
Share on other sites

Link to post
Share on other sites

 

Post the code you've written so far and what your problems are. We're here to help, not to write code for you :)

 

Also be sure to use code tags whenever posting code to the forum. You can do this with the blue < > symbol above the text box you write your replies in, or manually inside code like so

[code]// Put your code between the code tagspublic class Example{    ...}[/code]
 
{
    class Triangle
    {
        public double A;
        public double B;
        public double C;
        public double perimeter;
        public double CalcPerimeter()
        {
            return A + B + C;
        }
        
        
    }
    
}
{
    class EquilateralTriangle : Triangle
    {
        public EquilateralTriangle(double a)
        {
            A = a;
            B = a;
            C = a;
        }
    }
}
{
    class Program
    {
        static void Main(string[] args)
        {
            Triangle t1 = new Triangle(3.0, 4.0, 5.0);
            Console.WriteLine(t1.CalcPerimeter());
            EquilateralTriangle t2 = new EquilateralTriangle(3.5);
            Console.WriteLine(t2.CalcPerimeter());
        }
    }
}
Link to comment
Share on other sites

Link to post
Share on other sites

You didn't use code tags nor did you explain the problem you are having like I mentioned.

 

Anyway, your class Triangle is missing it's constructors.

 

Also, you need to call the base constructor with the EquilateralTriangle constructor. Documentation for that.

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×