인터페이스
꽁스짱
C#
0
1606
2021.02.15 22:55
namespace Class_make
{
interface Polygon
{
public int Area(int a, int b);
}
{
interface Polygon
{
public int Area(int a, int b);
}
class Square : Polygon
{
public int Area(int a,int b)
{
Console .WriteLine ("직사각형 면적");
return a * b ;
}
}
class Triangle : Polygon
{
double Area(int a, int b)
{
Console.WriteLine("삼각형 면적");
return a * b / 2;
{
public int Area(int a,int b)
{
Console .WriteLine ("직사각형 면적");
return a * b ;
}
}
class Triangle : Polygon
{
double Area(int a, int b)
{
Console.WriteLine("삼각형 면적");
return a * b / 2;
}
}
}
class Program
{
static void Main(string[] args)
{
Polygon p1 = new Triangle ();
p1.Area(5,4);
{
static void Main(string[] args)
{
Polygon p1 = new Triangle ();
p1.Area(5,4);
Polygon p2 = new Square();
p2.Area(6,7);
p2.Area(6,7);
}
}
}
}
}