Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In Linux terminal (using C) create a Bash script that outputs a checkerboard to the terminal. The board should be 8x8 and should alternate between

image text in transcribedimage text in transcribedimage text in transcribed

In Linux terminal (using C) create a Bash script that outputs a checkerboard to the terminal. The board should be 8x8 and should alternate between the black and white tiles. It should also take in an optional command line flag that flips the colors (i.e. white tiles become black tiles and black tiles become white tiles). # Script 1-Checkerboard DO NOT CHANGE # Constants used TILE-BLACK-"\033[0; 40m \033 [0;0m" TILE WHITE-"\033 [0:47m \033 [0;0m" SQUARES PER LINE 8 HALF_DIVISOR-2 NUM ITERATIONS 4 ERR-"\tERROR: Invalid flag given. " USAGE-"USAGE : . /checkerboard. sh [-r]" # # # DO NOT CHANGE # DO NOT CHANGE # DO NOT CHANGE # # DO NOT DO NOT CHANGE CHANGE DO NOT D0 NOT CHANGE CHANGE rotate flag-"f" # Parse command line arguments while getopts ":r" arg $@ do case $arg in # rotation wanted r) rotate flag-"t"; # Invalid flag provided ?) echo; echo -e "$ERR"; echo "$USAGE"; exit 1: esac done # Remove parsed option flags shift $( (OPTIND 1)) # YOUR CODE STARTS BELOW # FIXME: write a function that prints one row of the checkerboard. It # should look at the argument passed in to determine if it will start # by printing a white or black square. This is an optional method, but | # will help you implement the main method function printLine { # One way to define a function main() { # Another way to define a function counter 0 if [ $rotate-flag --"t" ]; then # This line creates a loop that will run NUM-ITERATIONS times until [ $counter -eq $NUM-ITERATIONS ]; do # FIXME: Use the print functions to draw two REVERSED rows of the boa rd done else until [ $counter -eq $NUM-ITERATIONS ]; do # FIXME: Use the print functions to draw two rows of the board done fi DO NOT CHANGE= main # Calls the main function to start the script up exit 0 In Linux terminal (using C) create a Bash script that outputs a checkerboard to the terminal. The board should be 8x8 and should alternate between the black and white tiles. It should also take in an optional command line flag that flips the colors (i.e. white tiles become black tiles and black tiles become white tiles). # Script 1-Checkerboard DO NOT CHANGE # Constants used TILE-BLACK-"\033[0; 40m \033 [0;0m" TILE WHITE-"\033 [0:47m \033 [0;0m" SQUARES PER LINE 8 HALF_DIVISOR-2 NUM ITERATIONS 4 ERR-"\tERROR: Invalid flag given. " USAGE-"USAGE : . /checkerboard. sh [-r]" # # # DO NOT CHANGE # DO NOT CHANGE # DO NOT CHANGE # # DO NOT DO NOT CHANGE CHANGE DO NOT D0 NOT CHANGE CHANGE rotate flag-"f" # Parse command line arguments while getopts ":r" arg $@ do case $arg in # rotation wanted r) rotate flag-"t"; # Invalid flag provided ?) echo; echo -e "$ERR"; echo "$USAGE"; exit 1: esac done # Remove parsed option flags shift $( (OPTIND 1)) # YOUR CODE STARTS BELOW # FIXME: write a function that prints one row of the checkerboard. It # should look at the argument passed in to determine if it will start # by printing a white or black square. This is an optional method, but | # will help you implement the main method function printLine { # One way to define a function main() { # Another way to define a function counter 0 if [ $rotate-flag --"t" ]; then # This line creates a loop that will run NUM-ITERATIONS times until [ $counter -eq $NUM-ITERATIONS ]; do # FIXME: Use the print functions to draw two REVERSED rows of the boa rd done else until [ $counter -eq $NUM-ITERATIONS ]; do # FIXME: Use the print functions to draw two rows of the board done fi DO NOT CHANGE= main # Calls the main function to start the script up exit 0

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

Master The Art Of Data Storytelling With Visualizations

Authors: Alexander N Donovan

1st Edition

B0CNMD9QRD, 979-8867864248

More Books

Students also viewed these Databases questions