CS 1050 Standard String Functions & File Processing Lab Report
Question Description
Description
We are all going stir-crazy from being stuck in our homes, and so my mind turns to Dungeons and Dragons.As it turns out, my character (Ahote) is stuck at home due to the Corona Virus as well.Since he isnt real, the best solution is for him to fight some monsters or watch them fight each other (dont try this at home!).
For the lab assignment, you will read data from a file called monster.csv.Your goal will be to read data for the following two creatures from this file and to have them fight each other:
Ahote
Air Elemental
Note that if the name of either of these creatures has a space in it, you will need to put it in quotation marks on the command-line if you are trying to do the bonus.
The first thing you need to do is get all of the starter code for this lab.To get started on this lab, type the following while logged in to tc.rnet.missouri.edu: (MAKE SURE TO DO THIS STEP)
cs1050start lab11
This command will create a directory called lab11.Go into that directory (cd lab11) and get a list of the files there (ls -la).Notice that there is a file called lab11.c.You can start editing this file to do your lab.Notice that there is a commented-out line that says SetStatus(0).Later on, if you want to see different results each time you run the program, you can just uncomment this line to make the fights truly random.
One more thing you should notice is that there is a header file called fight.h.This file contains the names of two functions that I have provided for you.One is the SetStatus() function previously mentioned.The other is called Fight() and you should call that function when you have all of the information from the monster.csv file you need.You will need the following stats for each monster: AC (armor class), HP (hit points), hitbonus (To Hit Bonus), a string the represents the damage for the first attack, and a string that represents the damage for the second attack (some creatures get two attacks).
If all of that sounds confusing, all you need to do is read the name of the monster, 3 integers (ac, hp, hitbonus), and 2 strings (attack1damage, and attack2damage) for each monster.Pass these parameters into the Fight() function, and you are good!
Instead of your usual command (compile lab11.c), you should just type in make.This will compile your program and make sure it is linked to the library that has the Fight() function in it. (CHECK THIS OUT)
Hints
- If you are having trouble understanding how things work, just call the Fight() function with some hard-coded data to try it out.Example: Fight(“JimR”,21,900,10,”5d6+5″,”5d12+5″,”Lar”,5,100,5,”1d6″,”N/A”);
- Hard-code your data file and the two creature types initially.You can change this later if you are doing the bonus.If you get things working with hard-coding, go ahead and submit your code in case you run out of time.You can always submit again.
- You might want to grab some of the code from your prelab.Reading the name of the creature and the attack damage strings is very similar to the way we read names in the prelab (since each of these ends when you hit a comma).
- Dont forget to check whether you have reached the end of the file.
- Dont forget the close the file when you are all done.
- If you get everything working, it is more fun to call SetSeed(0).That will set things to a random number, so you will get different results each time you run the program.You might want to wait and try this at the end, as it is easier to debug things if you get the same results each time you run it.
You could literally just add this example line to the lab11.c and then type make and then run ./a.out to see it work.
"Place your order now for a similar assignment and have exceptional work written by our team of experts, guaranteeing you "A" results."