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

Other questions on the subject: Engineering

image
Engineering, 04.07.2019 18:10, salazjlove
Which of the following refers to refers to how well the control system responds to sudden changes in the system. a)-transient regulation b)- distributed regulation c)-constant regulation d)-steady-state regulation
Answers: 1
image
Engineering, 04.07.2019 18:10, mirmir62
Machinery that is a key part of the process and without which the plant or process cannot function is classifed as: (clo4) a)-critical machinery b)-essential machinery c)-general purpose machinery d)-none of the specified options.
Answers: 1
image
Engineering, 04.07.2019 18:20, mjcbs21
What is the heat treatment of metals? what is the benefit of it? why and how it's useful? answer in details, do not write by hand.
Answers: 3
image
Engineering, 04.07.2019 19:20, zoebtharpe
Heat transfer by is the fastest mode of heat transfer that requires no intervening medium. a)-conduction b)-convection c)-radiation d)-conduction and convection
Answers: 1
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 in other subjects: