using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace ConsoleApplication1 { class Qian { private decimal yuanlai; private string name; public Qian(string name) { this.yuanlai = 0; this.name = name; Print("我的钱数", 0); } public bool Desposit(decimal jine) { if (jine <= 0) return false; yuanlai += jine; Print("借了别人",jine); return true; } public bool WithDraw(decimal jine) { if (jine > yuanlai || jine <= 0) return false; yuanlai -= jine; Print("借给别人", jine); return true; } private void Print(string operation, decimal jine) { Console.WriteLine("我的名字:{0}",name); Console.WriteLine("{0}:{1}",operation,jine); Console.WriteLine("现在的钱:{0}",yuanlai); Console.WriteLine("============================"); Console.ReadKey(); } } class Program { static void Main(string[] args) { Qian q = new Qian("我是LT"); bool succed = q.Desposit(10000); if (!succed) Console.WriteLine("他不借给我钱!"); succed = q.WithDraw(50000); if (!succed) Console.WriteLine("我不借给他钱!"); Console.ReadKey(); } } }