2012-11-25 125 views
-2

当我输出的pW它给我的原始值试图更新的值,在while循环更新后得到它

double plateWt = wWeight - bWval; 

    while (plateWt > 200 && plate100val > 0) { 
     plateWt = plateWt - 200; 
     plate100 ++; 
     plate100val --; 
    } 
    while (plateWt > 90 && plate45val > 0) { 
     plateWt = plateWt - 90; 
     plate45 ++; 
     plate45val --; 
    } 
    while (plateWt > 70 && plate35val > 0) { 
     plateWt = plateWt - 70; 
     plate35 ++; 
     plate35val --; 
    } 
    while (plateWt > 50 && plate25val > 0) { 
     plateWt = plateWt - 50; 
     plate25 ++; 
     plate25val --; 
    } 
    while (plateWt > 20 && plate10val > 0) { 
     plateWt = plateWt - 20; 
     plate10 ++; 
     plate10val --; 
    } 
    while (plateWt > 10 && plate5val > 0) { 
     plateWt = plateWt - 10; 
     plate5 ++; 
     plate5val --; 
    } 
    while (plateWt > 5 && plateQval > 0) { 
     plateWt = plateWt - 5; 
     plateQ ++; 
     plateQval --; 
    } 
    Log.i("LOG_TAG", "PlateWeight value: " + plateWt); 
    double pw = plateWt; 
    warmupPlatesOneTextView.setText(String.valueOf(pw)); 

11-25 15:16:16.867:I/LOG_TAG(21569) :PlateWeight值:5.0 11-25 15:16:16.883:I/LOG_TAG(21569):PlateWeight值:10.0 11-25 15:16:17.121:I/LOG_TAG(21569):PlateWeight值:45.0 11- 25 15:16:17.145:I/LOG_TAG(21569):PlateWeight值:45.0

+2

你能给出变量的起始值吗? – MrChaz

+0

original plateWt = 45,plate10val = 2,plate5val = 2 – wvmack

+2

正确缩进代码并使用调试器。 –

回答

0

在猜测我会说它会在第一次正确运行(导致5) 之后,假设全局变量,while循环将不会执行。 在代码中插入一个中断点并逐步检查代码

+0

谢谢,我会试一试 – wvmack

+0

我明白了。由于多次调用该函数,我的plateValues已经用完了。 – wvmack

-1

放入日志语句并确保正在输入和执行while循环,并且wats plate10值?

+1

这应该是一个评论。 –

+0

没有选项可以显示评论。所以我回答了。不一定是downvote的理由。 – Priety