// Corrected compile-time error
or
// Corrected run-time error
behind each correction that you made.
Submit the corrected Bug1.java.
public int getTurns()
to this class that returns the total amount by which this bug (the solution for homework 4A) has turned. You should return an angle between 0 and 359 degrees. For example,
Bug2 bugsy = new Bug2(); bugsy.turn(300); bugsy.turn(50); int turns = bugsy.getTurns(); // sets turns to 350 bugsy.turn(40); turns = bugsy.getTurns(); // sets turns to 30
You may assume that turn
has been called only with integers
between 0 and 359.
Hints:
Submit Bug2.java and Bug2Tester.java, testing the above scenario.
totalScore | quizCount | score | newTotalScore | newQuizCount -----------+-----------+-------+---------------+------------- 0 | | | | | 0 | | | | | 8 | | | | | 8 | | | | | 1 8 | | | | | 1 | | | | | | X | X | | 7 | | | | | 15 | | | | | 2 15 | | | | | 2 | | | | | | X | X
Consider this class and the sequence of calls
Bug3 carol = new Bug3(); carol.moveBackward(2); carol.turnLeft();
Show the values for x
, y
, dx
,
dy
, n
, and newDx
, as they are set
when executing the three statements given above. Including the removal of
local variables, there are 12 changes.
Submit a file problem3.txt
in which you fill in this
form:
x |y |dx |dy |n |newDx --+--+---+---+--+---- | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
Submit HorizontalFlag.java.