Write a C# program that uses the Up, Down , Right (and possibly Left) arrows of the keyboard (or keypad) to move a ball. (note the Up arrow is called "Up" with ASCII code 38, Down arrow is called Down with ASCII code 40, Right arrow is called Right with ASCII code. You can also use the 4 keys ijkl, commonly used in DOS game programming.

(a) Draw a grid of 5 horizontal lines, 5 vertical lines, a blue pond in the middle occupying 5 squares with a text Pond in the middle, a ball at the lower left corner, and texts called Start and End. This is shown exactly as in Figure 1 here. Change the text in the title bar from "Dr. Lin's key control ball movement" to your own text or change the color of ball from green to another color.

(b) Add code to make up, down, and right arrows used to move the green ball at the lower left corner to the lower right corner. In other words, up arrow will move the ball up one square, right arrow moves that one square to the right etc.

(c) Enhance the code at the end from the previous parts above so that the ball can only follow the path from lower left to lower right. Print out error messages when the player intends to move the ball out of the path.

Figure: see image.

Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.