Question
C CODING You are tasked with writing a program that will display where a character can move on the gameboard. The gameboard will be specified
C CODING
You are tasked with writing a program that will display where a character can move on the gameboard. The gameboard will be specified by width and height. You do not need to display any other attribute on the board besides the character which is denoted by C in the grid space and how many spaces they can move after they have moved to that position.
The character has a starting position which is denoted by x and y as well as a walk limit.
If the character cannot reach the grid space than it should be a space
| |
if the the character can reach the grid space, than it should display how many gridspaces they can still move. In the example, if the character had a walk limit of 7 and could move 5 grid spaces they can only move another 2 spaces from that space
|2|
Input is from command line arguments (argv), you will need to distinguish if the input is also a valid integer.
The arguments are assumed to be in this order width height x y walk_limit
./movement 4 4 1 3 2
Width and Height arguments have to be > 0 and a valid integer
x argument has to be >= 0 and < width
y argument has to be >= 0 and < height
walk_limit has to be >= 0
The number of user arguments must be equal to 5
Example Case 1, width=4, height=4, x=1, y=3, limit=2:
./movement 4 4 1 3 2
+-------+ | | | | | | |0| | | |0|1|0| | |1|C|1|0| +-------+
Example Case 2, width=4, height=4, x=1, y=3, limit=1:
./movement 4 4 1 3 1
+-------+ | | | | | | | | | | | |0| | | |0|C|0| | +-------+
Example Case 3, width=5, height=4, x=1, y=3, limit=5:
./movement 5 4 1 3 5
+---------+ |1|2|1|0| | |2|3|2|1|0| |3|4|3|2|1| |4|C|4|3|2| +---------+
Example Case 4, width=6, height=5, x=1, y=4, limit=5:
./movement 6 5 1 4 5
+-----------+ |0|1|0| | | | |1|2|1|0| | | |2|3|2|1|0| | |3|4|3|2|1|0| |4|C|4|3|2|1| +-----------+
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started