count - Java counting obstacles -
i making program robot count how many times hits obstacle seconds running. want know can use count times.
for example;
if (robot.isobstacle);
start counting every time isobstacle occurs , stop when there no obstacle.
finch frobot = new finch(); frobot.setwheelvelocities(250,250); long before = system.currenttimemillis(); while (system.currenttimemillis() - before < msfinch*1000) if(frobot.isobstacle() == true);{ system.out.println(obstaclecount); obstaclecount++; } if(frobot.isobstacle() == false);{ system.out.println("no obstacles hit"); }
this doesn't seem work know have done wrong.
your while
loop seems fishy. want start new block there.
while (system.currenttimemillis() - before < msfinch*1000) {
your if
syntax wrong. remove ;
after condition:
if(frobot.isobstacle() == true) { system.out.println(obstaclecount); obstaclecount++; } if(frobot.isobstacle() == false) { system.out.println("no obstacles hit"); }
Comments
Post a Comment