I have a project that calls for me to create a moving bug. It only needs to move as its called to in the code, no input is required. We're supposed to create a Bug class, then a turn, move, and getPosition method. I think I've pretty much got everything except for the turn part. I could create a method that defines which direction the "Bug" is set to move, but I don't know how to turn the "Bug" drawing around to face another direction. We're only moving horizontally.
Here's the problem:
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 it can turn to change its direction. In each move, its position changes by one unit in the current direction. Provide a constructor
public void turn()
public void move()
public int getPosition()
Bug bugsy = new Bug(10);
What I have is incomplete (not sure if the parameters are right to draw the bug), but I think I can handle it once I figure out what to do for the "turn" method.