十年网站开发经验 + 多家企业客户 + 靠谱的建站团队
量身定制 + 运营维护+专业推广+无忧售后,网站问题一站解决
这个是用面向对象的方法来实现加,减,乘,除的计算,使用了“简单工厂的设计模式”。
创新互联专注于曲沃网站建设服务及定制,我们拥有丰富的企业做网站经验。 热诚为您提供曲沃营销型网站建设,曲沃网站制作、曲沃网页设计、曲沃网站官网定制、重庆小程序开发公司服务,打造曲沃网络公司原创品牌,更为您提供曲沃网站排名全网营销落地服务。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace 简单公司实现计算1
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("请输入第一个数字:");
double n1= Convert.ToDouble( Console.ReadLine());
Console.WriteLine("请输入第二个数字:");
double n2= Convert.ToDouble(Console.ReadLine());
Console.WriteLine("请输入一个操作符");
string oper= Console.ReadLine();
CalFather cal = Result(oper, n1, n2);
double result= cal.GetResult();
Console.WriteLine(result);
Console.ReadKey();
}
///
return cal;
}
}
///
public CalFather(double One,double Two)
{
this.NumberOne = One;
this.NumberTwo = Two;
}
public abstract double GetResult();
}
///
}
public override double GetResult()
{
return this.NumberOne + this.NumberTwo;
}
}
///
}
public override double GetResult()
{
return this.NumberOne - this.NumberTwo;
}
}
///
}
public override double GetResult()
{
return this.NumberOne * this.NumberTwo;
}
}
///
}
public override double GetResult()
{
return this.NumberOne / this.NumberTwo;
}
}
}