Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Java question Due Date: As noted on Blackboard Concepts: Scanner, loops, classes, objects, client classes Point value: 100 point Note: Name your classes XXX Bug

Java question
image text in transcribed
image text in transcribed
Due Date: As noted on Blackboard Concepts: Scanner, loops, classes, objects, client classes Point value: 100 point Note: Name your classes XXX Bug and Xxx BugSimulation (5 points) The class Bug simulates a bug moving along a horizontal line. The horizontal line is organized like the X axis of the coordinate plane with the center at position 0, extending infinitely to the left and right of the center A Bug has a position and direction. The Bug's position is the location of the Bug on the horizontal line. The Bug's direction is either left or right. A Bug moves and turns. The move method simulates the bug moving one unit in the direction it is facing. The turn method simulates changing the bug's direction (from left to right or from right to left). The getPosition method returns the current position of the bug. The getDirection method returns the current direction of the bug When a Bug object is first created, it is always facing to the right. Its position may or may not be provided. If it is not provided, the bug is positioned at "0". The Bug class must allow for a Bug to be created at a specified position or to default to 0. A client class called, BugSimulation simulates a bug moving on the horizontal line. The program will Ask the user for the Bug's initial position Create a Bug object facing right at the position entered by the user Print a message that a Bug object has been created at that position with initial direction. . . Ask the user how many times the Bug should move Simulate the Bug moving that many times . Ask the user how many times the Bug should turn . Simulate the Bug turning that many times Print the Bug's position and direction Ask the user how many times the Bug should move . Simulate the Bug moving that many times Print the Bug's position and direction Enter the starting position of the bug Creating Bug at position 3 facing Right

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_step_2

Step: 3

blur-text-image_step3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Visual Basic6 Database Programming

Authors: John W. Fronckowiak, David J. Helda

1st Edition

ISBN: 0764532545, 978-0764532542

More Books

Students also viewed these Databases questions

Question

=+1 What are the major issues related to international T&D?

Answered: 1 week ago