using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace NameSpaceOperation
{
publicabstractclass Operation
{
publicint NumberOne { get; set; }
publicint NubmerTwo { get; set; }
publicOperation(int a,int b)
{
this.NumberOne = a;
this.NubmerTwo = b;
}
publicabstractintGetResult();
}
}
(2)加法子类Add
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace NameSpaceOperation
{
publicclass Add : Operation
{
publicAdd(int a, int b) : base(a, b)
{
}
publicoverrideintGetResult()
{
returnthis.NumberOne + this.NubmerTwo;
}
}
}
(3)减法子类Sub
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace NameSpaceOperation
{
publicclass Sub : Operation
{
publicSub(int a, int b) : base(a, b)
{
}
publicoverrideintGetResult()
{
returnthis.NumberOne - this.NubmerTwo;
}
}
}
(4)乘法子类Mul
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace NameSpaceOperation
{
publicclass Mul : Operation
{
publicMul(int a, int b) : base(a, b)
{
}
publicoverrideintGetResult()
{
returnthis.NumberOne * this.NubmerTwo;
}
}
}
(5)除法子类Div
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace NameSpaceOperation
{
publicclass Div : Operation
{
publicDiv(int a, int b) : base(a, b)
{
}
publicoverrideintGetResult()
{
returnthis.NumberOne / this.NubmerTwo;
}
}
}