using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace inter
{
interface operations
{
void operation();
int add();
int sub();
}
public class math1: operations
{
public int x=10;
public int y=20;
public int add()
{
return x + y;
}
public int sub()
{
return x - y;
}
public void operation()
{
Console.WriteLine("x1: {0}", x);
Console.WriteLine("y1:{0}", y);
Console.WriteLine("base add:{0}", add());
}
}
public class math2: math1,operations
{
public int add()
{
return x + y;
}
public int sub()
{
return x*y;
}
public void operation()
{
Console.WriteLine("\nmath 2 sub :{0}", sub());
Console.WriteLine("\n math2 add :{0}",add());
}
}
public class math3 : math1, operations
{
//public int a=10;
//public int b=50;
public int add()
{
return x+y;
}
public int sub()
{
return x-y;
}
public void operation()
{
Console.WriteLine("a: {0}", x);
Console.WriteLine("b:{0}", y);
Console.WriteLine("\nmath3 add:{0}", add());
Console.WriteLine("math3 sub:{0}", sub());
}
}
class Tester
{
static void Main(string[] args)
{
//math1 m1 = new math1();
math2 m2 = new math2();
math3 m3 = new math3();
//m1.operation();
m2.operation();
m3.operation();
Console.ReadKey();
}
}
}
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace inter
{
interface operations
{
void operation();
int add();
int sub();
}
public class math1: operations
{
public int x=10;
public int y=20;
public int add()
{
return x + y;
}
public int sub()
{
return x - y;
}
public void operation()
{
Console.WriteLine("x1: {0}", x);
Console.WriteLine("y1:{0}", y);
Console.WriteLine("base add:{0}", add());
}
}
public class math2: math1,operations
{
public int add()
{
return x + y;
}
public int sub()
{
return x*y;
}
public void operation()
{
Console.WriteLine("\nmath 2 sub :{0}", sub());
Console.WriteLine("\n math2 add :{0}",add());
}
}
public class math3 : math1, operations
{
//public int a=10;
//public int b=50;
public int add()
{
return x+y;
}
public int sub()
{
return x-y;
}
public void operation()
{
Console.WriteLine("a: {0}", x);
Console.WriteLine("b:{0}", y);
Console.WriteLine("\nmath3 add:{0}", add());
Console.WriteLine("math3 sub:{0}", sub());
}
}
class Tester
{
static void Main(string[] args)
{
//math1 m1 = new math1();
math2 m2 = new math2();
math3 m3 = new math3();
//m1.operation();
m2.operation();
m3.operation();
Console.ReadKey();
}
}
}
No comments:
Post a Comment