Question: Using Java occasional turn. Have a race between the bugs and print the position of each bug after eac at the end of 10 moves.
occasional turn. Have a race between the bugs and print the position of each bug after eac at the end of 10 moves. h move and declare a winner o (This is put in for student practice. It does fit real well with the bug race but I wanted to give students practice with multi-object methods.) In the middle of the race bug 1 gets "help" from bug 2 and bug 3 gets help from bug 4. So after 5 moves, set bugl to the sum of bug! and bug2 and bug3 = bug3-bug4. Use code such as bug bugl.add(bug2). When two bugs are added, add their positions and use the direction (left or right) of the bug that provided the "help"-bug2 (or bug4) in this case Note about grading: If you can get 1 bug working (constructor, moving/turning for 10 time steps) then you will get (up to) 14 points. Thus, work on getting one bug working then it should be straightforward to get the array of bugs in a race Sample output (initial position 5) Del On your mark get set [00.. Position of bugs +04 66 +03 7 5 7 +02 8 4 +01 937 +00 10 2 6 +011 117 5 -E12126 6 +013 115 5 +012 10 6 +011 9 7 3 .] The winner is bug 1
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
