职工工资
using System; public class Company { protected int m=800; protected int n=300; public virtual void pay() { Console.WriteLine("The is your pay:"+m+"(yuan)!"); } } class Boss:Company { public override void pay() { Console.WriteLine("Boss,This is your pay:"+(m+2*n)+"(yuan)"); } } class Worker:Company { public override void pay() { Console.WriteLine("Worker,This is your pay!"+m); } }
class intput { static void Main() { Console.WriteLine("Input your style! \n boss or worker ?"); string c=Console.ReadLine(); if (c=="boss") { Boss b=new Boss(); b.pay(); } if(c=="worker") { Worker w =new Worker(); w.pay(); } System.Threading.Thread.Sleep(3000); } }