Question: Requirements for Implementation: The implementation of this assignment must be Object-Oriented with the following requirements: The solution should include at least the following classes besides

Requirements for Implementation:
The implementation of this assignment must be Object-Oriented with the following requirements:
The solution should include at least the following classes besides the main test class:
- Animal
- Turtle
- Hare
- Command
- Command Collector
- Command Executor
- Pen
The GitHub shell is provided and details are sent in a separate announcement.
----------------------------- GitHub code -------------------------------------
// Exercise 8.21: TurtleGraphics.cs // Drawing turtle graphics based on turtle commands. using System;
public class TurtleGraphics { const int MAXCOMMANDS = 100; // maximum size of command array const int SIZE = 20; // size of the drawing area
static int[,] floor; // array representing the floor static int[,] commandArray; // list of commands
static int count; // the current number of commands static int xPos; // the x Position of the turtle static int yPos; // the y Position of the turtle
// enters the commands for the turtle graphics public static void Main(string[] args) { count = 0; commandArray = new int[MAXCOMMANDS, 2]; floor = new int[SIZE, SIZE];
Console.Write("Enter command (9 to end input): "); int inputCommand = int.Parse(Console.ReadLine());
while (inputCommand != 9 && count
// prompt for forward spaces if (inputCommand == 5) { Console.Write("Enter forward spaces: "); commandArray[count, 1] = int.Parse(Console.ReadLine()); }
++count;
Console.Write("Enter command (9 to end input): "); inputCommand = int.Parse(Console.ReadLine()); }
ExecuteCommands(); }
// executes the commands in the command array public static void ExecuteCommands() { int commandNumber = 0; // the current position in the array int direction = 0; // the direction the turtle is facing int distance = 0; // the distance the turtle will travel int command; // the current command bool penDown = false; // whether the pen is up or down xPos = 0; yPos = 0;
command = commandArray[commandNumber, 0];
// continue executing commands until either reach the end // or reach the max commands while (commandNumber
command = commandArray[++commandNumber, 0]; } }
// method to turn turtle to the right public static int TurnRight(int d) { return ++d > 3 ? 0 : d; }
// method to turn turtle to the left public static int TurnLeft(int d) { return --d
// method to move the pen public static void MovePen(bool down, int[,] floor, int dir, int dist) { int j; // looping variable
// determine which way to move pen switch (dir) { case 0: // move to right for (j = 1; j
yPos += j - 1; break;
case 1: // move down for (j = 1; j
xPos += j - 1; break;
case 2: // move to left for (j = 1; j = 0; j++) { if (down) { floor[xPos, yPos - j] = 1; } }
yPos -= j - 1; break;
case 3: // move up for (j = 1; j = 0; j++) { if (down) { floor[xPos - j, yPos] = 1; } }
xPos -= j - 1; break; } }
// method to display array drawing public static void PrintArray(int[,] floor) { // display array for (int i = 0; i
Console.WriteLine(); } } }
8.21 (Turtle Graphics) The Logo language made the concept of turtle graphics famous. Imagine a mechanical turtle that walks around the room under the control of a C# app. The turtle holds a pen in one of two positionsup or down. While the pen is down, the turtle traces out shapes as it moves, and while the pen is up, the turtle moves about freely without writing anything. In this prob- lem, you'll simulate the operation of the turtle and create a computerized sketchpad. Use a 20-by-20 rectangular array floor that's initialized to 0. Read commands from an array that contains them. Keep track at all times of the current position of the turtle and whether the pen is currently up or down. Assume that the turtle always starts at position (0,0) of the floor with its pen up. The set of turtle commands your app must process are shown in Fig. 8.25. Suppose that the turtle is somewhere near the center of the floor. The following app would draw and display a 12-by-12 square, leaving the pen in the up position: 2. 5,12 3 5,12 3 5,12 3 5,12 1 6 9 As the turtle moves with the pen down, set the appropriate elements of array floor to 1s. When the 6 command (display the array) is given, wherever there's a 1 in the array, display an asterisk or any character you choose. Wherever there's a 0, display a blank. Write an app to implement the turtle graphics capabilities discussed here. Write several turtle graphics apps to draw interesting shapes. Add other commands to increase the power of your turtle graphics language. Command Meaning 1 Pen up 2 3 4 5, 10 Pen down Turn right Turn left Move forward 10 spaces (replace 10 for a different number of spaces) Display the 20-by-20 array End of data (sentinel) 6 9 Fig. 8.25 | Turtle graphics commands
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
