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, 04.07.2019 18:10
Water in a partially filled large tank is to be supplied to the roof top, which is 8 m above the water level in the tank, through a 2.2-cm-internal-diameter pipe by maintaining a constant air pressure of 300 kpa (gage) in the tank. if the head loss in the piping is 2 m of water, determine the discharge rate of the supply of water to the roof top in liters per second.
Answers: 3
question
Engineering, 04.07.2019 18:10
Which of the following components of a pid controlled accumulates the error over time and responds to system error after the error has been accumulated? a)- proportional b)- derivative c)- integral d)- on/off.
Answers: 2
question
Engineering, 04.07.2019 18:10
The flow rate of air through a through a pipe is 0.02 m5/s. a pitot static tube is placed in the flow. the radius of the pitot static tube is 1 mm. assuming the flow to be steady and the air to be at 300k, calculate the difference in total and static pressure if the diameter of the pipe is: (a) d 0.1 m d 0.05 m (c) d 0.01 m
Answers: 2
question
Engineering, 04.07.2019 18:20
A3-mm-thick panel of aluminum alloy (k 177 w/m-k, c 875 j/kg-k and ? = 2770 kg/m) is finished on both sides with an epoxy coating that must be cured at or above t,-150°c for at least 5 min. the production line for the curing operation involves two steps: (1) heating in a large oven with air at ts,0-175°c and a convection coefficient of h, 40 w/m2. k, and (2) cooling in a large chamber with air at 25°c and a con- vection coefficient of he 10 w/m2.k. the heating portion of the process is conducted over a time interval te which exceeds the ime required to reach 150°c by 5 min (h = r + 300 s). the coating has an emissivity of ? = 0.8, and the temperatures of the oven and chamber walls are 175 and 25°c, respectively. if the panel is placed in the oven at an initial temperature of 25°c and removed from the chamber at a safe-to-touch tempera ture of 37°c, what is the total elapsed time for the two-step curing operation?
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
Physics, 30.08.2020 01:01
question
History, 30.08.2020 01:01
question
Chemistry, 30.08.2020 01:01
question
History, 30.08.2020 01:01
question
Mathematics, 30.08.2020 01:01
Questions on the website: 13722362