Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Imagine a mouse that walks within a 50 by 50 array. The mouse holds a pen in one of two positions: up or down. While

Imagine a mouse that walks within a 50 by 50 array. The mouse holds a pen in one of two positions: up or down. While the pen is up, the mouse does not write anything. While the pen is down, the mouse marks each array location it passes by. You will read a sequence of commands (one per line) from standard input (I suggest using an input text file and use input redirection) and walk the mouse. The mouse always starts at location (0,0) with its pen up. Possible commands are:

1 Pen up

2 Pen down

3 Turn right

4 Turn left

5,n Move forward n spaces

6 Print the array, putting an asterisk for marked locations, putting a space for unmarked locations. However, put one extra space character between consecutive columns.

9 End of data marker.

For example, the following set of commands should draw a 10 by 10 array as:

* * * * * * * * * *

* *

* *

* *

* *

* *

* *

* *

* *

* * * * * * * * * *

2

5,10

3

5,10

3

5,10

3

5,10

1

6

9

Provide at least three input text files to draw interesting shapes. Make sure to check for cases when the mouse tries to move outside the array, and do not let it move beyond array boundaries.

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: 3

blur-text-image

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

Logidata+ Deductive Databases With Complex Objects Lncs 701

Authors: Paolo Atzeni

1st Edition

354056974X, 978-3540569749

More Books

Students also viewed these Databases questions

Question

5. How does unpredictability teach flexibility?

Answered: 1 week ago

Question

Q.No.1 Explain Large scale map ? Q.No.2 Explain small scale map ?

Answered: 1 week ago

Question

1. Signs and symbols of the map Briefly by box ?

Answered: 1 week ago