Problem: Bugs are simple creatures that only know how to walk towards other bugs. Bugs maintain information about their (x, y) position; by which it can tell if they are standing next to other bugs. Watch the following video: bug movement. Create a java project that simulate bugs movement. You need to write a class “Bug" that models a bug moving along a straight line and it can turn to change its direction counterclockwise (i.e. 90 degree to the left; north → west → south → east → north). In each move, its position changes by one unit in the current direction. Details of the “Bug" class is described below. Your simulator should read information of an unknown number of "Bug" objects from an input file called “Bugs.txt". Each line represents a bug and the initial position and facing direction of this particular bug. Keeping the first bug position as a reference the simulator should move the second bug next to the first bug forming a cluster and its final position and direction should be stored into a list. The simulator should then read the third bug and moves it towards either the first or the second bug, then add its information to the list. The consequent bugs should move next to any bug in the list (i.e. randomly selected), as soon as it join the cluster its information should be stored in the list. This process should continue until no bugs remain. Notice that at the end each bug has its unique position; i.e. no two bugs can stand at exactly the same (x, y) position. When a bug starts moving, the simulator should randomly select its path vertically or horizontally towards the cluster. This results different possible bug cluster shapes each time you run the simulator. See the figure 1 below as an example of bug movement simulator resulting a cluster. E Bug Simulator Bug Simulator - O x Original positions Possible Cluster sample-1 Possible Cluster sample-2
Problem: Bugs are simple creatures that only know how to walk towards other bugs. Bugs maintain information about their (x, y) position; by which it can tell if they are standing next to other bugs. Watch the following video: bug movement. Create a java project that simulate bugs movement. You need to write a class “Bug" that models a bug moving along a straight line and it can turn to change its direction counterclockwise (i.e. 90 degree to the left; north → west → south → east → north). In each move, its position changes by one unit in the current direction. Details of the “Bug" class is described below. Your simulator should read information of an unknown number of "Bug" objects from an input file called “Bugs.txt". Each line represents a bug and the initial position and facing direction of this particular bug. Keeping the first bug position as a reference the simulator should move the second bug next to the first bug forming a cluster and its final position and direction should be stored into a list. The simulator should then read the third bug and moves it towards either the first or the second bug, then add its information to the list. The consequent bugs should move next to any bug in the list (i.e. randomly selected), as soon as it join the cluster its information should be stored in the list. This process should continue until no bugs remain. Notice that at the end each bug has its unique position; i.e. no two bugs can stand at exactly the same (x, y) position. When a bug starts moving, the simulator should randomly select its path vertically or horizontally towards the cluster. This results different possible bug cluster shapes each time you run the simulator. See the figure 1 below as an example of bug movement simulator resulting a cluster. E Bug Simulator Bug Simulator - O x Original positions Possible Cluster sample-1 Possible Cluster sample-2
Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
Related questions
Question
write easy java program.
![%0. l. *
ど 1:1
4G
HW2 SP21.pdf
Sultan Qaboos University
Department of Computer Science
COMP2202: Fundamentals of Object Oriented Programming
Assignment2 (Due 29/03/2021 @ 11:55PM) – Spring2021
The purpose of this assignment is to practice OOP with Decisions, Loops, Arrays and ArrayList,
Input/Output Files, and Constructing Objects and Classes. Create a NetBeans project named
HW2_YourId. Develop classes for the required solutions.
Important: Apply good programming practices:
Provide API documentation comments for your class(s), class constructor(s) and method(s)
using the Java standard form for documentation comments discussed in this course.
Use meaningful variable and constant names.
Show your name, university id and section number as a comment at the start of each class.
Submit to Moodle the compressed file of your project with name “HW2_yourlID" along with
a PDF file that contains all your code.
Problem:
Bugs are simple creatures that only know how to walk towards other bugs. Bugs maintain
information about their (x, y) position; by which it can tell if they are standing next to other bugs.
Watch the following video: bug movement.
Create a java project that simulate bugs movement. You need to write a class “Bug" that models a
bug moving along a straight line and it can turn to change its direction counterclockwise (i.e. 90
degree to the left; north → west → south → east → north). In each move, its position changes by
one unit in the current direction. Details of the “Bug" class is described below.
Your simulator should read information of an unknown number of "Bug" objects from an input
file called “Bugs.txt". Each line represents a bug and the initial position and facing direction of this
particular bug. Keeping the first bug position as a reference the simulator should move the second
bug next to the first bug forming a cluster and its final position and direction should be stored into
a list. The simulator should then read the third bug and moves it towards either the first or the
second bug, then add its information to the list. The consequent bugs should move next to any bug
in the list (i.e. randomly selected), as soon as it join the cluster its information should be stored in
the list. This process should continue until no bugs remain. Notice that at the end each bug has its
unique position; i.e. no two bugs can stand at exactly the same (x, y) position. When a bug starts
moving, the simulator should randomly select its path vertically or horizontally towards the cluster.
This results different possible bug cluster shapes each time you run the simulator. See the figure 1
below as an example of bug movement simulator resulting a cluster.
A Bug Simulator
A Bug Simulater
Bug Simulator
Original positions
Possible Cluster sample-1
Possible Cluster sample-2
1
Figure 1 Example of bug movement simulator forming a cluster
As soon as the final cluster is formed, your program should display the details of the bug available in
the simulator in an output file “BugsSimulator.txt". Figure 2 and 3 shows a sample input file and the
corresponding possible output files forming different clusters.
Bug Class: a bug has a code, original location at a point with integer coordinates, faces north, east,
south, or west and keeps a record of all its current movement position. The class generate a unique
for each new "bug" object created starting with value “b-I00". It also includes the following
s:
A default constructor that initializes bug's code to "b-xxx"; where "xxx" is the next code
sequence number in the class, positions to (0,0), and direction to WEST.
A constructor that is given bug's information: starting location, facing direction and generates
bug code similarly to the default constructor.
Accessor methods to access all the instance variables and the simulated movements of the
bug.
Mutator methods that change the instance variables to given values and they make the change
for only suitable values.
turn method that changes the direction of the bug counterclockwise.
move method that moves the bug by one unit in the direction it is facing.
T。Lし。](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2Ffe932cfd-8e7c-442a-a999-1084880b09b3%2F1892630c-9fde-43b6-b1c2-f8b0a09d0e39%2Fgf16m2p_processed.jpeg&w=3840&q=75)
Transcribed Image Text:%0. l. *
ど 1:1
4G
HW2 SP21.pdf
Sultan Qaboos University
Department of Computer Science
COMP2202: Fundamentals of Object Oriented Programming
Assignment2 (Due 29/03/2021 @ 11:55PM) – Spring2021
The purpose of this assignment is to practice OOP with Decisions, Loops, Arrays and ArrayList,
Input/Output Files, and Constructing Objects and Classes. Create a NetBeans project named
HW2_YourId. Develop classes for the required solutions.
Important: Apply good programming practices:
Provide API documentation comments for your class(s), class constructor(s) and method(s)
using the Java standard form for documentation comments discussed in this course.
Use meaningful variable and constant names.
Show your name, university id and section number as a comment at the start of each class.
Submit to Moodle the compressed file of your project with name “HW2_yourlID" along with
a PDF file that contains all your code.
Problem:
Bugs are simple creatures that only know how to walk towards other bugs. Bugs maintain
information about their (x, y) position; by which it can tell if they are standing next to other bugs.
Watch the following video: bug movement.
Create a java project that simulate bugs movement. You need to write a class “Bug" that models a
bug moving along a straight line and it can turn to change its direction counterclockwise (i.e. 90
degree to the left; north → west → south → east → north). In each move, its position changes by
one unit in the current direction. Details of the “Bug" class is described below.
Your simulator should read information of an unknown number of "Bug" objects from an input
file called “Bugs.txt". Each line represents a bug and the initial position and facing direction of this
particular bug. Keeping the first bug position as a reference the simulator should move the second
bug next to the first bug forming a cluster and its final position and direction should be stored into
a list. The simulator should then read the third bug and moves it towards either the first or the
second bug, then add its information to the list. The consequent bugs should move next to any bug
in the list (i.e. randomly selected), as soon as it join the cluster its information should be stored in
the list. This process should continue until no bugs remain. Notice that at the end each bug has its
unique position; i.e. no two bugs can stand at exactly the same (x, y) position. When a bug starts
moving, the simulator should randomly select its path vertically or horizontally towards the cluster.
This results different possible bug cluster shapes each time you run the simulator. See the figure 1
below as an example of bug movement simulator resulting a cluster.
A Bug Simulator
A Bug Simulater
Bug Simulator
Original positions
Possible Cluster sample-1
Possible Cluster sample-2
1
Figure 1 Example of bug movement simulator forming a cluster
As soon as the final cluster is formed, your program should display the details of the bug available in
the simulator in an output file “BugsSimulator.txt". Figure 2 and 3 shows a sample input file and the
corresponding possible output files forming different clusters.
Bug Class: a bug has a code, original location at a point with integer coordinates, faces north, east,
south, or west and keeps a record of all its current movement position. The class generate a unique
for each new "bug" object created starting with value “b-I00". It also includes the following
s:
A default constructor that initializes bug's code to "b-xxx"; where "xxx" is the next code
sequence number in the class, positions to (0,0), and direction to WEST.
A constructor that is given bug's information: starting location, facing direction and generates
bug code similarly to the default constructor.
Accessor methods to access all the instance variables and the simulated movements of the
bug.
Mutator methods that change the instance variables to given values and they make the change
for only suitable values.
turn method that changes the direction of the bug counterclockwise.
move method that moves the bug by one unit in the direction it is facing.
T。Lし。
![3
Sample input/output files:
O Bugs.bxt - Notepad
100
100
SOUTH
186
153
NORTH
127
135
90
104
21
49
138
121
SOUTH
36
EAST
145
NORTH
88
WEST
17
SOUTH
45
WEST
81
SOUTH
120
76
NORTH
157
81
148
183
101
WEST
150
EAST
95
EAST
113
WEST
130
38
124
58
8
SOUTH
125
EAST
10
WEST
128
WEST
138
11
EAST
146
118
46
118
187
107
30
|140
|163
147
45
123
SOUTH
123
EAST
4
NORTH
65
NORTH
39
WEST
EAST
NORTH
19
127
9
SOUTH
182
NORTH
103
SOUTH
114
EAST
123
118
EAST
|167
132
113
NORTH
63
NORTH
163
150
WEST
2
117
95
172
102
71
90
|171
162
WEST
139
EAST
WEST
EAST
82
130
25
NORTH
145
NORTH
95
SOUTH
21
NORTH
198
127
NORTH
29
127
157
4
120
NORTH
163
WEST
8
NORTH
SOUTH
SOUTH
178
112
185
144
49
EAST
Figure 2 Sample input file
4
Bugfinal.bt - Notepad
BugFinal.tt - Notepad](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2Ffe932cfd-8e7c-442a-a999-1084880b09b3%2F1892630c-9fde-43b6-b1c2-f8b0a09d0e39%2Fv5j9dug_processed.jpeg&w=3840&q=75)
Transcribed Image Text:3
Sample input/output files:
O Bugs.bxt - Notepad
100
100
SOUTH
186
153
NORTH
127
135
90
104
21
49
138
121
SOUTH
36
EAST
145
NORTH
88
WEST
17
SOUTH
45
WEST
81
SOUTH
120
76
NORTH
157
81
148
183
101
WEST
150
EAST
95
EAST
113
WEST
130
38
124
58
8
SOUTH
125
EAST
10
WEST
128
WEST
138
11
EAST
146
118
46
118
187
107
30
|140
|163
147
45
123
SOUTH
123
EAST
4
NORTH
65
NORTH
39
WEST
EAST
NORTH
19
127
9
SOUTH
182
NORTH
103
SOUTH
114
EAST
123
118
EAST
|167
132
113
NORTH
63
NORTH
163
150
WEST
2
117
95
172
102
71
90
|171
162
WEST
139
EAST
WEST
EAST
82
130
25
NORTH
145
NORTH
95
SOUTH
21
NORTH
198
127
NORTH
29
127
157
4
120
NORTH
163
WEST
8
NORTH
SOUTH
SOUTH
178
112
185
144
49
EAST
Figure 2 Sample input file
4
Bugfinal.bt - Notepad
BugFinal.tt - Notepad
Expert Solution
![](/static/compass_v2/shared-icons/check-mark.png)
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution!
Trending now
This is a popular solution!
Step by step
Solved in 2 steps
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Recommended textbooks for you
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
![C How to Program (8th Edition)](https://www.bartleby.com/isbn_cover_images/9780133976892/9780133976892_smallCoverImage.gif)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
![Database Systems: Design, Implementation, & Manag…](https://www.bartleby.com/isbn_cover_images/9781337627900/9781337627900_smallCoverImage.gif)
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
![Programmable Logic Controllers](https://www.bartleby.com/isbn_cover_images/9780073373843/9780073373843_smallCoverImage.gif)
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education