Description
https://docs.google.com/document/d/19FC9iITJzKUlrhBK-Rsf2AmmwNwIqrDY13s SwV5VEW0/edit?usp=sharing
Documentation Header Reminder
Before you start your assignment, you will need to add documentation similar to what we demonstrated in the first few lectures.
Function Prototype Documentation Reminder
In the function prototype section of your C++ program, remember to add documentation to each function similar to what was demonstrated in lectures.
Separate File Compilation
For this assignment (and onward), you will submit multiple C++ compilable files containing a program written in C++. Name your file a meaningful name and give it a proper extension (.h, .hpp, .cpp). Also, make sure that you compile and run your program using the GNU (g++) compiler before submitting to make sure that it will work.
Background:
Specifications
You will need to use a 2-dimensional array to represent the world. It should be a 10×10 array of characters. In this world, an underscore (‘_‘) shall be used to represent a country not currently infested with anything, a capital B shall be used to represent a country infested with bees, A capital W shall be used to represent a country infected with wasps, and a capital T shall be used to represent a country infested with tarantula hawk wasps.
Your program needs to be written so that it will take input from an input file, and write the output to an output file. In your input file, called “input.txt”, there will first be 10 lines, each with 10 characters. These characters will be used to represent the initial state of the world. On the next several lines, there will be two positive integers. These numbers represent the coordinates that are about to be airdropped with bees. For example, if the next 3 lines of input.txt have the numbers 8 1, 0 9, and 4 4, then bees will be airdropped at coordinate positions (8,1), (0,9), and (4,4). Here is a display of how your coordinate system should function:
Airdropping
– If bees are airdropped into an empty country, that country will become infested with bees.
– If bees are airdropped into a country already infested with something, there will be an outbreak of whatever bug was already infesting that country. Every surrounding country will be infested.
B B B
B Airdrop at->1,1 B B B
B B B
W W W
W Airdrop at->1,1 W W W
W W W
T T T
T Airdrop at->1,1 T T T
T T T
Infesting
If a bee infests a country already occupied by bees, they will mutate into wasps. Similarly, if a wasp infests a country already infested by wasps, they will mutate into tarantula hawk wasps. If a tarantula hawk wasp infects a country already infested by tarantula hawk wasps, no change will occur.
B B B W
B Airdrop at->1,1 B B B
B B B
(An outbreak of bees occurred after bees were airdropped into the country at 1,1). Nearby countries were infested, and as the country to the north east was
already occupied by bees, they mutated into wasps.)
W W W T
W W Airdrop at->1,1 T W W
W W W
T T T T T
T Airdrop at->1,1 T T T
T T T
If a bee attempts to infest a country already occupied by wasps or tarantula hawk wasps, they will be unsuccessful. Similarly, If wasps attempt to infest a country infested by tarantula hawk wasps, they will be unsuccessful.
T T B T T W
W B W Airdrop at->1,1 W B W
T T T B T
(After an airdrop of bees at (1,1), the T’s remained T’s, and the W’s remained W’s. The bee infested country to the North-east mutated into wasps, and the country to the south received an infestation of bees.
T T T T T T
T W T Airdrop at->1,1 T W T
T T T T T T
Overall Program Flow
1. Read the first 10 lines of “input.txt” and set the values in a 2D array.
2. For every pair of integers after that in “input.txt”, airdrop bees onto the corresponding location of the world.
3. Resolve any outbreaks and/or mutations that were caused by the airdrop.
4. Repeat airdropping until there are no coordinates left in input.txt
5. Output the final state of the world to a new file, called “output.txt”
Other Notes
● You must use multiple files for this assignment.
● Be very careful to not try to assign values outside of your 10×10 array. You will get a segmentation fault error.
● You are encouraged to design and use your own functions to make the assignment easier.
● Make your own test files! Try running the code with your own input.txt files to make sure it works as you expect it to.
● We do not care about anything that you output to the console, we will only check the contents of your output.txt file. If there is no file, your program will be considered to have no output at all.
Sample Output 1
(input.txt)
B_____TTB_ ______TBB_ ______BBB_
___WWW____
___WTW____
___WWWTT__
_____T_T__ _W___TTT__ __________
__________
4 0
0 0
4 4
1 7
7 1
6 6 6 6
0 0
(This text in black is NOT part of the output, this is here to show the results of performing each airdrop.) After (4,0):
B _ _ _ _ _ T T B _
_ _ _ _ _ _ T B B _
_ _ _ _ _ _ B B B _
_ _ _ W W W _ _ _ _
B _ _ W T W _ _ _ _
_ _ _ W W W T T _ _
_ _ _ _ _ T _ T _ _
_ W _ _ _ T T T _ _
_ _ _ _ _ _ _ _ _ _
_ _ _ _ _ _ _ _ _ _
(A bee was airdropped into (4,0)) After (0,0):
B B _ _ _ _ T T B _
B B _ _ _ _ T B B _
_ _ _ _ _ _ B B B _
_ _ _ W W W _ _ _ _
B _ _ W T W _ _ _ _
_ _ _ W W W T T _ _
_ _ _ _ _ T _ T _ _
_ W _ _ _ T T T _ _
_ _ _ _ _ _ _ _ _ _
_ _ _ _ _ _ _ _ _ _
(A bee was airdropped into (0,0), causing an outbreak of bees into neighboring countries.)
After (4,4):
B B _ _ _ _ T T B _
B B _ _ _ _ T B B _
_ _ _ _ _ _ B B B _
_ _ _ T T T _ _ _ _
B _ _ T T T _ _ _ _
_ _ _ T T T T T _ _
_ _ _ _ _ T _ T _ _
_ W _ _ _ T T T _ _
_ _ _ _ _ _ _ _ _ _
_ _ _ _ _ _ _ _ _ _
(A bee was airdropped into (4,4), causing an outbreak of tarantula hawk wasps. Neighboring countries with wasps were mutated into tarantula hawk wasps.)
After (1,7):
B B _ _ _ _ T T W _
B B _ _ _ _ T B W _
_ _ _ _ _ _ W W W _
_ _ _ T T T _ _ _ _
B _ _ T T T _ _ _ _
_ _ _ T T T T T _ _
_ _ _ _ _ T _ T _ _
_ W _ _ _ T T T _ _
_ _ _ _ _ _ _ _ _ _
_ _ _ _ _ _ _ _ _ _
(A bee was airdropped into (1,7), causing an outbreak of bees. Neighboring countries with bees were mutated into wasps, whereas neighboring countries with tarantula hawk wasps remained tarantula hawk wasps.)
After (7,1):
B B _ _ _ _ T T W _
B B _ _ _ _ T B W _
_ _ _ _ _ _ W W W _
_ _ _ T T T _ _ _ _
B _ _ T T T _ _ _ _
_ _ _ T T T T T _ _
W W W _ _ T _ T _ _
W W W _ _ T T T _ _
W W W _ _ _ _ _ _ _
_ _ _ _ _ _ _ _ _ _
(A bee was airdropped into (7,1), causing an outbreak of wasps.) After (6,6):
B B _ _ _ _ T T W _
B B _ _ _ _ T B W _
_ _ _ _ _ _ W W W _
_ _ _ T T T _ _ _ _
B _ _ T T T _ _ _ _
_ _ _ T T T T T _ _
W W W _ _ T B T _ _
W W W _ _ T T T _ _
W W W _ _ _ _ _ _ _
_ _ _ _ _ _ _ _ _ _
(A bee was dropped into (6,6). No other effects occurred.)
After (6,6):
B B _ _ _ _ T T W _
B B _ _ _ _ T B W _
_ _ _ _ _ _ W W W _
_ _ _ T T T _ _ _ _
B _ _ T T T _ _ _ _
_ _ _ T T T T T _ _
W W W _ _ T B T _ _
W W W _ _ T T T _ _
W W W _ _ _ _ _ _ _
_ _ _ _ _ _ _ _ _ _
(A bee was airdropped into (6,6), causing an outbreak of bees. No neighboring countries were affected as they are all infested with tarantula hawk wasps.
After (0,0):
B W _ _ _ _ T T W _
W W _ _ _ _ T B W _
_ _ _ _ _ _ W W W _
_ _ _ T T T _ _ _ _
B _ _ T T T _ _ _ _
_ _ _ T T T T T _ _
W W W _ _ T B T _ _
W W W _ _ T T T _ _
W W W _ _ _ _ _ _ _
_ _ _ _ _ _ _ _ _ _
(A bee was airdropped into (0,0), causing an outbreak of bees. Neighboring countries with bees mutated into wasps.)
An Infestation of Bees
(output.txt)
BW____TTW_
WW____TBW_
______WWW_
___TTT____
B__TTT____
___TTTTT__
WWW__TBT__
WWW__TTT__
WWW_______
__________
Reviews
There are no reviews yet.