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
The filament of an incandescent lamp has a temperature of 2000k. calculate the fraction of radiation emitted in the visible light band if the filament is approximated as blackbody
Answers: 2
question
Engineering, 04.07.2019 18:10
The higher the astm grain size number, the finer the gran is. a)-true b)-false
Answers: 2
question
Engineering, 04.07.2019 18:10
Ifa component is made of two or more materials with different modulus of elasticity (e), it is called a composite member and we calculate the factor·n". mention the formula for calculating n". also, ifn> 1, explain what will happen to the 1. transformed.gi) ifn 1, what will happen to the material when transformed material when
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
question
Mathematics, 15.04.2020 23:35
question
Mathematics, 15.04.2020 23:35
Questions on the website: 13722360