James Sea wrote:
I have changed my code...
Put print methods in the accelerate and brake methods and you will see they are indeed being called. What did it print for distance? Was it the same every time?James Sea wrote:. . . something with my random number is messed up because it never calls the accelerate or brake methods
Junilu Lacar wrote:And you still haven't answered my previous questions:
1. Where in your code are you changing the value of your loop variables such that the loop will eventually terminate?
2. When either vehicle reaches 500, will your while-loop terminate if the other vehicle still hasn't reached 500?
Campbell Ritchie wrote:
Put print methods in the accelerate and brake methods and you will see they are indeed being called. What did it print for distance? Was it the same every time?James Sea wrote:. . . something with my random number is messed up because it never calls the accelerate or brake methods
Campbell Ritchie wrote:Please go through your code and tell us all the lines where distance is being changed.
And why isn't distance a field of the Car class?
James Sea wrote:2. Yes it will terminate because I put the "||" known as "or" in the while loop so once one of the distances gets to 500 it should stop
Now that is new. You are going places () if you can change the loop header like that. But why are you using the || operator. Read the loop header carefully pronouncing || “OR”.James Sea wrote:. . . I just made distance a field of the Car class but I must be confused because Im thinking every time it goes through the loop it updates the distance because i have distance = get speed / 60. . . .
James Sea wrote:Updated Code
Carey Brown wrote:I find your use of blank lines and indentation to be misleading. Only use single blank line instead of double (or more) lines.
James Sea wrote:Updated Code
Did you see how Paul cut 87% off of his electric heat bill with 82 watts of micro heaters? |