2013-04-24 62 views
0
using System; 
using System.Collections.Generic; 
using System.Text; 

namespace Bank 
{ 
public class Overdraft : Account 
{ 
    double credit; 
    double inter = 0.15; 
    public double Credit 
    { 
     get { return credit; } 
    } 
    public Overdraft() 
    { 

    } 
    public Overdraft(String acno, String nam, double amt, double cred) 
     : base(acno, nam, amt) 
    { 
     this.credit = cred; 
    } 
    public override bool deposit(double amount) 
    { 
     amt += amount; 
     return true; 
    } 

    public override bool withdraw(double amount) 
    { 
     if (amount <= (credit + amt)) 
     { 
      amt -= amount; 

      if (amt < 0) 
      { 
       credit -= Math.Abs(amt); 
       due = Math.Abs(amt); 
       interest(); 
      } 
      return true; 
     } 

     else 
      Console.WriteLine("\n!!!!Credit Limit Crossed!!!!"); 
     return false; 
    } 

    public void interest() 
    { 
     due = due * inter; 
     Console.WriteLine("The Interest for due amount is Rs. {0}", due); 
     return true; 
    } 

    public override string ToString() 
    { 
     return string.Format("Account Details: \nACC NO = {0} \nName = {1} \nBalance = Rs. {2}\nCredit =Rs. {3} \n", accno, name, amt, credit); 
    } 

} 

}访问return语句Windows窗体

以上是我的代码的dll类之一。问题是我应该如何传递Windows窗体中的Console.Writeln语句以及ToString方法。或者任何人都可以告诉我如何在消息框中的表单中获得这些声明。

+0

你肯定需要花更多的时间在设计上,你写的东西没什么意义。发现难以使用的是自动结果。使用像codereview.stackexchange.com这样的网站找到愿意审查并提出改进建议的人。 – 2013-04-24 13:29:01

回答

0

请勿在您的dll中使用Console.WriteLine。 UI(WinForms)中的客户端代码应检查布尔返回值/调用ToString()并向用户提供相关信息。

PS。考虑将双打更改为小数以存储金额。

+0

@Jacob Konecki如何调用WinForms中的ToString方法,这是我在上面的代码中写的?任何示例?最后我会更改为十进制,谢谢你的支持。 – 2013-04-24 10:34:59

+0

@ChetanGoenka'var overdraftAccount = new Overdraft(); overdrafeAccount.ToString();' - 只需获取路由帐户的实例并在其上调用'ToString()'。 – 2013-04-24 10:48:19