Coding Assignment 4 CSE 1320 Fall 2021 The format and content of the output is not a suggestion – it is the specification given to you to follow so please follow. Points will be lost for not following...

Need to complete the following assignment


Coding Assignment 4 CSE 1320 Fall 2021 The format and content of the output is not a suggestion – it is the specification given to you to follow so please follow. Points will be lost for not following the specification. This includes using the specified functions. This is essential to the grading process. Create an ASCII drawing tool. 1. Please see the examples in this document to see how tool runs and how it reacts to valid and invalid input. 2. This assignment includes using two provided files – DrawTool.h and DrawTool.c. You are required to use these files and you are not allowed to alter them. You must write your code to use these library files. You will not be submitting these two files as part of your assignment, so if you alter them to make your code work, then your code will fail when the GTA compiles with the original versions. 3. Use the following pseudocode to get you started on the program. Include “DrawTool.h” in your Code4.c file. In main() Declare a 2D array with a max size of 20 for both dimensions. Anything larger than 20 tends to wrap and be messy on the screen. This max size is set as a #define in DrawTool.h. You should not hardcode 20 anywhere in your program – use the #define from DrawTool.h. Call function InitializeMap from DrawTool Parameters array user-chosen size of the map (pass by reference). Call function PrintInstructions() from DrawTool No parameters Call function to PrintMap() from DrawTool Parameters array user-input size of the map Prompt for a draw command and read it using fgets(). Then use strtok() to parse out just the draw command (Q, P, V or H). If the user entered 'Q' or 'q' as the draw command, then your program should quit. If the user did not enter Q, then use strtok() to parse out the rest of the components of the draw command. If the mark value is not entered, then ‘X’ should be used as a default value. The draw command should be entered as described in the instructions. Each draw command is one prompt – not multiple prompts. All draw commands should be validated to ensure they will not go out of bounds. Check for out of bounds for both the coordinate and line. You cannot draw a line that will end of out of bounds. For the point command ('P'), update that point in the array with the input mark. For the horizontal ('H') and vertical ('V') commands, call function DrawLine() from DrawTool. Drawing a line means marking those spots with the input mark in the array. This function should be passed the array, the row,col from the command, the action (H or V), the number of spots to mark and the mark itself. The function will use for loops to appropriately move through the array and mark the spots. Any draw command that do not start with Q, P, V or H will generate an output of "That draw command is unknown". Draw commands of P, V and H can be entered in upper or lowercase. Use function toupper() to convert all input commands to uppercase. The program will continue to prompt for draw commands and display the array until the user quits. 4. Create the makefile to compile Code4.c and DrawTool.c. You are required to use the makefile template provided with this assignment. Be sure to include your name in the first line comment (comments in makefiles start with #) 5. Files to submit in a zip file named “Code4_xxxxxxxxxx.zip” 1. Code4_xxxxxxxxxx.c 2. Submit a file that you created named "input.txt" that contains the draw commands to output your initials. Be sure to state in your assignment submission what those initials are. Your input file needs to contain ALL of the commands to complete a full run. See video attached to assignment for how to use this file and how your program should behave. Test this process using the UNIX redirect command as shown in the video. 3. makefile ATTENTION : Do not alter the DrawTool.c or DrawTool.h files. You are not submitting those; therefore, any changes you make to them to make your code work will not be present when your code is graded. Miscellaneous Notes 1. Array is statically allocated using a define set to the maximum value (20). The user will be prompted for what size array they want to display within that 20x20 array. When passing the array, you must use the max size, not the user input size in function calls/definitions. 2. The GTA will be running your program with your file and a file of draw commands that are both valid and invalid to test the functionality of your program. Be sure to test for and reject commands that go out of the bounds of the array. Be sure to test that you can draw along the edges of your array. 3. Using the following command ./Code4_xxxxxxxxxx.e < input.txt="" is="" using="" the="" unix="" redirect="" command.="" the="">< symbol="" takes="" the="" contents="" of="" input.txt="" and="" dumps="" it="" completely="" into="" stdin.="" your="" program="" then="" reads="" from="" stdin="" for="" each="" prompt="" rather="" than="" asking="" you.="" during="" this="" process,="" the="" actual="" commands="" do="" not="" show="" on="" the="" screen="" since="" they="" are="" not="" being="" typed.="" it="" will="" be="" very="" important="" to="" this="" process="" that="" your="" file="" have="" unix="" end="" of="" lines="" rather="" than="" mac.="" if="" you="" are="" on="" a="" mac,="" you="" will="" need="" to="" run="" your="" input="" file="" through="" this="" unix="" command="" to="" transform="" the="" mac="" cr="" eols="" to="" unix="" lf="" eols.="" cat="" file.txt="" |="" tr="" '\r'="" '\n'="" |="" tr="" -s="" '\n'=""> newfile.txt file.txt is the original file and newfile.txt is the new file with UNIX LF EOLs. If you do not do this step, your program will not behave correctly because it will try to process the \r symbol left by Mac at the end of each line. GET YOUR PROGRAM WORKING BEFORE YOU TRY THE REDIRECT AND INPUT FILE. There is nothing you need to add to the program to make it work with the input file. You are not opening the file, you are not coding anything to handle a file. We are simply using the UNIX redirect command ‘<’ to="" give="" input="" to="" the="" program="" from="" a="" file="" rather="" than="" the="" user="" manually="" typing="" it.="" your="" code="" is="" the="" same="" whether="" you="" are="" typing="" in="" the="" draw="" commands="" or="" reading="" them="" from="" a="" file.="" sample="" input.txt="" file="" –="" you="" need="" to="" create="" your="" own="" file="" with="" your="" own="" initials="" 15="" -="" v(0,0,10)d="" h(0,1,2)d="" h(9,1,2)d="" v(1,3,8)d="" v(0,5,10)m="" v(0,9,10)m="" p(1,6,1)m="" p(2,7,1)m="" p(1,8,1)m="" v(0,11,10)f="" h(0,12,3)f="" h(4,12,2)f="" q="" instructions="" draw="" commands="" start="" with="" p="" for="" a="" single="" point="" h="" for="" a="" horizontal="" line="" v="" for="" a="" vertical="" line="" after="" the="" p/v/h,="" enter="" a="" row,col="" coordinate="" and="" the="" number="" of="" spots="" to="" mark="" enclosed="" in="" ()="" and="" separated="" by="" commas="" and="" then="" the="" character="" for="" the="" mark.="" 'x'="" will="" be="" used="" if="" a="" mark="" is="" not="" entered.="" for="" example,="" p(2,3,1)*="" start="" at="" point="" 2,3="" in="" the="" array="" and="" mark="" one="" spot="" with="" an="" *.="" for="" p,="" the="" 3rd="" parameter="" is="" ignored.="" v(1,2,3)$="" start="" at="" point="" 1,2="" in="" the="" array="" and="" mark="" the="" next="" 3="" spots="" down="" from="" the="" current="" position="" with="" $="" h(4,6,7)#="" start="" at="" point="" 4,6="" in="" the="" array="" and="" mark="" the="" next="" 7="" spots="" to="" the="" right="" with="" #="" coordinates="" out="" of="" range="" and="" lines="" drawn="" past="" the="" borders="" are="" not="" allowed.="" enter="" q="" at="" the="" draw="" command="" prompt="" to="" quit="" press=""> to continue Running program with one type of each command student@maverick:/media/sf_VM/CSE1320/CA4$ ./Code4_1000074079.e How big is the array? (Enter a value between 1 and 20) 17 What is the background character? . Draw commands start with P for a single point H for a horizontal line V for a vertical line After the P/V/H, enter a row,col coordinate and the number of spots to mark enclosed in () and separated by commas and then the character for the mark. 'X' will be used if a mark is not entered. For example, P(2,3,1)* start at point 2,3 in the array and mark one spot with an *. For P, the 3rd parameter is ignored. H(1,2,3)$ start at point 1,2 in the array and mark the next 3 spots to the right with $ V(4,6,7)# start at point 4,6 in the array and mark the next
Dec 09, 2021
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here