Java 会计程序的方法

Java 会计程序的方法,java,object,accounting,Java,Object,Accounting,我正试图用Java编写一个记帐程序,为此我需要编写一个方法,该方法需要从提示符处获得记帐记录 System.out.println("Write your accounting record"); String accountingRecord= console.nextLine(); String[] parts= accountingRecord.split(" "); // Split the String into three parts (debit,credit and amm

我正试图用Java编写一个记帐程序,为此我需要编写一个方法,该方法需要从提示符处获得记帐记录

System.out.println("Write your accounting record"); 

String accountingRecord= console.nextLine();

String[] parts= accountingRecord.split(" ");
// Split the String into three parts (debit,credit and ammount)

debit =parts[0];
// the debit could be an account which is declared before e.g. "Bank, Liabilities...
credit=parts[1];
//should be too an account which is declared before.

int ammount= Integer.parseInt(parts[2]);

account.accounting(debit,credit,ammount);

现在来回答我的问题,静态方法“会计”需要两个对象,借方和贷方对象(例如银行、负债),当然还有金额。如何在提示中键入对象的名称?

您可能需要在代码中创建
贷方
借方
对象,例如
Credit c=new Credit(Credit)
我在之前的步骤中已经这样做了,例如使用抵押账户
System.out.println(“键入账户名称”);字符串namemotage=console.nextLine();负债账户抵押=新负债账户(namemotage)
您希望在一行中包含3个变量。如果有人遗漏了任何变量,您将如何确定他遗漏了哪一个输入?我认为您的方法不正确,我可以看到设计中的一些缺陷。您可能应该在代码中创建
贷方
借方
对象,例如
贷方c=新信用(信用)
我在之前的一个步骤中已经这样做了,例如使用抵押账户
System.out.println(“键入账户名称”);字符串namemotage=console.nextLine();负债账户抵押=新负债账户(名称抵押)一行中应包含3个变量。如果有人遗漏了任何变量,你将如何确定他遗漏了哪些输入?我不认为你的方法是正确的,我看不出设计中有什么缺陷。