subject
Engineering, 24.10.2021 14:30 arod20061

Design a class to model a bug moving along a horizontal line on a game board. The bug moves either in the right or left direction. Initially, the bug
moves to the right, but it can turn to change its direction from left to right or
right to left. In each move, its position changes by one unit in the current
direction.
(2 points) Provide the constructor that sets the initial position and
direction(right) of the Bug. (2 points) Design the methods that help the bug to
turn and move. (1 point) Also, write a method to get the current position of the bug.
(2 points) Test the model class by the following steps.
1. Create a bug called bugsy with initial position 10.

2. Move the bugsy.

Now the position is 11
3. Turn the bugsy:

Now the direction is left.
4. Move the bugsy
Now the position is 10

Design the UML class diagram (3 points) and write the code for the above scenario.

ansver
Answers: 3

Another question on Engineering

question
Engineering, 03.07.2019 14:10
Line joining liquid phase with liquid and solid phase mixture is known as: a) liquidus b) solidus c) tie line d) none of the mentioned
Answers: 2
question
Engineering, 04.07.2019 18:10
Draw the engineering stress-strain curve for (a) bcc; (b) fcc metals and mark important points.
Answers: 1
question
Engineering, 04.07.2019 18:10
A-mn has a cubic structure with a0 0.8931 nm and a density of 7.47 g/cm3. b-mn has a different cubic structure, with a0 0.6326 nm and a density of 7.26 g/cm3. the atomic weight of manganese is 54.938 g/mol and the atomic radius is 0.112 nm. determine the percent volume change that would occur if a-mn transforms to b-mn.
Answers: 2
question
Engineering, 04.07.2019 18:10
Which of the following ziegler nichols tuning methods the response of the controller to a step input should exhibit an s-shaped curve? a)-open loop mode b)-closed loop mode c)-both modes (open & closed) d)-none of the modes (open & closed)
Answers: 3
You know the right answer?
Design a class to model a bug moving along a horizontal line on a game board. The bug moves either...
Questions
question
Mathematics, 08.06.2021 05:10
question
Chemistry, 08.06.2021 05:10
question
Mathematics, 08.06.2021 05:10
question
Mathematics, 08.06.2021 05:10
Questions on the website: 13722360