the program is returning -500 which I don't understand (程序返回-500,我不明白)
Ok, initial balance is 15000 then 2 transactions that should deduct 250 each (好吧,初始余额为15000,则2笔交易应分别扣除250笔)
iteration balList balDisplay
0 15000 15000 set by if(i == 0) {list.get(i).getBalance()}
1 +/-250 14750 set by else {list.get(1).getBalance() - list.get(0).getBalance}
2 250 -500 set by else {list.get(2).getBalance() - list.get(1).getBalance}
iteration 0 indicates that balance
of list[0]
was initially 15000 (迭代0表示list[0]
balance
最初是15000)
iteration 1 indicates that balance
of list[1]
was initially +250 or -250, displayed value is 14750 (15000-250). (迭代1表示list[1]
balance
最初为+250或-250,显示值为14750(15000-250)。) calculation is list.get(1).getBalance() - list.get(0).getBalance
(计算是list.get(1).getBalance() - list.get(0).getBalance
)
- assuming it was +250, calculation gives -14750 (假设是+250,计算得出-14750)
- assuming it was -250, calculation gives -15250 (假设是-250,计算得出-15250)
Since the display displays 14750 it must display the calculated amount, but inverted (amount*-1), which is not included in the code snippets presented. (由于显示屏显示14750,因此它必须显示计算出的数量,但是要反转(数量* -1),这不包括在显示的代码片段中。)
iteration 2 : following from 1 we can assume, that balance
of list[2]
is initially +250, balDisplay should be 0 (250-250), but is -500. (迭代2 :从1开始,我们可以假设list[2]
balance
最初为+ 250,balDisplay应该为0(250-250),但为-500。)
This is the best what I could provide given the available information. (给定可用信息,这是我能提供的最好的方法。) The analysis leads to the conclusion that the displayed balance of row 3 should be zero, but it is -500. (分析得出的结论是,第3行的显示余额应为零,但应为-500。) There isn't anything available that would explain this. (没有任何可用的方法可以解释这一点。) On the other hand, the balance also couldn't be 14500 either. (另一方面,余额也不能是14500。)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…