Q:

Multiple Inheritance using C# Language

0

This Program is used to demonstrate the Multiple Inheritance concept

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

using System;

public class Shape

{

public void setWidth(int w)

  {   

    width = w;    

  }

public void setHeight(int h)

  { 

     height = h;   

 }

protected int width;

protected int height;

}

public interface PaintCost                 

  {  

      int getCost(int area);  

  }

class Rectangle : Shape,PaintCost   

{

public int getArea()

  {   

    return(width * height);   

  }

public int getCost(int area)

  {

     return area *70;     

  }

}

class RectangleTester

{

public static void Main()

{

Rectangle Rect=new Rectangle();

int area;

Rect.setWidth(5);

Rect.setHeight(7);

area =Rect.getArea();

Console.WriteLine("\nTotal area: {0}",Rect.getArea());

Console.WriteLine("\nTotal paint cost: ${0}",Rect.getCost(area));

}

}

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now