Question: Here's the code I have. the problem is that it gives me an error and highlights the bug.move(); saying there is an exception in the

 Here's the code I have. the problem is that it gives

me an error and highlights the bug.move(); saying there is an exception

in the thread main. Any help would be appreciated! EGR 140: Computer

Programmin,g Assigned: Wednesday, 31 October 2018 Due: Monday, 5 November 2018 (class

Here's the code I have. the problem is that it gives me an error and highlights the bug.move(); saying there is an exception in the thread main. Any help would be appreciated!

EGR 140: Computer Programmin,g Assigned: Wednesday, 31 October 2018 Due: Monday, 5 November 2018 (class time) Points: 20 Write an error-free Java program to do the following things. . Write a class Bug that models a bug moving along a horizontal line. The bug moves either to the right or left. Initially, the bug moves to the right but at random times it will turn and change its direction. In each move, its position changes by one unit in the current direction. Provide a constructor: public Bug(int initialPosition) Provide methods such as void turn(), void move(), int getPosition() and any others that you need The main program should construct four bugs (you can use an array), have them all start at position 5 (you have to use the constructor!), make them move and turn them approximately 30% of the time. The bugs should turn independently of each other

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!