Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

**Updated to clarify** Note: My professor uses only Linux and although he does not expect us to use Linux, he expects our programs to run

**Updated to clarify** Note: My professor uses only Linux and although he does not expect us to use Linux, he expects our programs to run properly on his end. Also, this is an introductory C++ class so I cannot used advanced libraries. This is an animation program without any specific guidelines as to what the animation has to be, only that it has to read a command file and animate based on the input file.

Update: To answer the question, the screen size is 80x25 (80 chars across by 25 lines) and I've bolded it below.

Description

This project is meant to display animation on the screen based upon commands provided by an input file. It will read in a command file and perform each action, line by line. In this way, the program will act as an "animation engine".

You may assume a screen size of 80x25 (80 chars across by 25 lines).

Input

The command file is a file containing keywords followed by arguments. It may also contain blank lines and/or comments. Both are optional but your program must be able to support them.

Also, the command input file will be provided via a "command line parameter" (see below).

Commands

The following commands are the minimal set your program must support:

Command Args Description
clear* Clears the screen
setms n Sets the pause milliseconds to n.
setfg n Sets the text color to n (should only be 30-39)
setbg n Sets the background color to n (should only be 40-49)
pause Pauses the processing for whatever time last setms value was.
slow Pause afer every line of command input (not including blanks and comments)
fast Pause only when the pause command is encountered (i.e. turns off pause after every command)
plot* row col char Places the cursor at (row, col) and prints char
hplot* row col char cnt Places the cursor at (row, col) and prints cnt /char/s to the right.
vplot* row col char cnt Places the cursor at (row, col) and prints cnt /char/s down.
text* row col string Places the cursor at (row, col) and prints string
move* row col h w Dr Dc Moves the contents of the box at (row, col), with height h and width w, Dr and Dc spaces
copy* row col h w Dr Dc Copies the box at (row, col), with height h and width w, to (row + Dr, col + Dc)
// {comment} Comment line; entire line is ignored by program
quit Notifies the program to stop reading input

* After any cursor involved action, put the cursor back at (0,0). It will improve the visual.

Output

The output of your program is two-fold. On screen, the user will see your beautiful animated artwork. Additionally, you will output information to a log file. The log file shall be namedproject2.log and will contain information of any erroneous commands encountered.

For example, consider the following input file:

clear setms 250 plo 10 10 ^ pause cop 10 20 5 5 20 10 quit 

The output log file should contain something like:

$ cat project2.log Error: Line 4 - bad command "plo", skipping. Error: Line 6 - bad command "cop", skipping. $ 

The log file should be re-created/overwritten for every execution of the program.

Execution

I will be running your programs in one of the following two ways:

 $ ./project2 input.txt or $ ./project2 input.txt > output.txt 

Input File as Command-Line Parameter

To get the input file as a command-line parameter, we need to now add parameters to the main() and use those like so:

int main ( int cnt, char* args[] ) { string command_file = argv[ 1 ]; // continue as normal } 

Don't worry about what the params mean, we'll learn those next week (but would have been too close to the due date).

WARNING: if you don't put a filename as the command line parameter, the program will crash. Don't worry about this, you are not currently responsible for handling that:

$ ./project2 input.dat // program runs as normal $ ./project2 terminate called after throwing an instance of 'std::logic_error' what(): basic_string::_S_construct null not valid Aborted 4 

Assumptions

You may assume the following:

The screen is 80 characters across by 25 lines down.

The commands in the command file are all lower-case.

The row and col arguments to the commands are within valid ranges (i.e. no "negative" rows or cols)

Any char argument is in fact only 1 character

Any deviations in a command file that violate these assumptions are not your responsibility to handle in code.

You may not assume the following:

The command keywords are typed correctly (i.e. no typos)this is the purpose of the log file.

Color arguments are in valid ranges (log errors)

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

Students also viewed these Databases questions

Question

What are the stages of project management? Write it in items.

Answered: 1 week ago