Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please help! I need assistance with building program written in Programming C under the listed specifications and restrictions. The problem is stated directly below. Problem:

Please help! I need assistance with building program written in Programming C under the listed specifications and restrictions. The problem is stated directly below. Problem: Dragon Games! Now that your dragon is fully trained, he or she can participate in the games at the yearly festivals! One popular game is similar to the human game of Red Rover. Dragons begin in two teams. Two dragons one from each team will compete head to head. The losing dragon must join the winners team. The game ends when an entire team is defeated. Since your dragon is the newest trained dragon, they must prove themselves by starting as a team of one. They will face off against a team of 5 other dragons. You will need to choose your opponents carefully to maximize your dragons chances of winning the game! Before each match, present the user with the following menu: 1) View Home Team 2) View Away Team 3) Continue That way, you can view the stats of your dragons (the home team) and the stats of the enemy dragons (the away team). When you are ready to continue you can choose which dragons from each team that will compete. The matches should continue until one team contains all six dragons and the other team has zero dragons left to compete. To make the testing of the program easier, your program will read in all of the dragon data from an input file. The name of this file should be specified by the user. Input Specification The input file will contain six lines of data. The first line of the file will contain the single dragon that begins on the home team. The other five lines of data will contain the five dragons that begin on the away team.Each line of data is organized the same way: Where is a string that is guaranteed not to exceed 19 characters and each score is an integer. Output Specification All output should go to the screen. When the user selects continue, first show them the home team. This listing should show each dragons name and combined score. Dragons should be labeled with an integer specifier starting at zero. Ask the user to select a dragon to send over. Then, show them the away team. This listing should show each dragons name and combined score. Dragons should be labeled with an integer specifier starting at zero. Ask the user to select a dragon for the home team to target. Then check the two selected dragons combined scores. Combined scores are obtained by adding the three dragon values together (agility, intelligence, and strength). The dragon with the higher score wins, but the home team wins if the scores are tied. The losing dragon joins the other time. Print out the results using the following format: defeats ! will join the team! Where all values in < brackets > are strings. Then update both teams. The losing dragon should be added to the last open spot of the winning team. If this causes a gap in the losing team, move the dragon in the last spot of the losing team into the gap. Finally, check to see if either team has won. A team wins when all six dragons are on the team. Print out the winning team: The home team has won! or The away team has won! Implementation Restrictions You must use the following constants: #define arraylength 6 #define strlength 20 You must use the following structure to store information: struct dragon { char name[strlength]; int strength; int intelligence; int agility; }; It is not sufficient to simply have the structure in your program. You must use it to store information and process operations throughout the program. Though function prototypes will not be provided, it is expected that you follow good programming design and create several functions with well-specified tasks related to the solution of this problem. Make sure to pay very careful attention to parameter passing. Hints: Create two arrays of structures: one to represent the home team and one to represent the away team. The maximum number of dragons that can be on a team is 6. Create two integer values to represent the current size of the teams. The home team should start at size 1 and the away team should start at size 5. Use pass by reference parameters for your functions. In your parameter list, pass the needed arrays of dragons and the size of each array to avoid out of bounds errors. This will help ensure that any changes made to the dragon teams in the functions will be reflected in main. Use the prewritten string functions when dealing with strings: use strcpy whenever you want to copy the contents of one string into another, instead of the equals sign. Whenever you add a dragon to any team, make sure you add it to the first open slot on the team. Whenever you remove a dragon from any team, make sure you copy the dragon in the last spot on the team into the vacated spot (unless the dragon leaving the team is already in the last spot). For example, if the dragon to be removed is in index 3 and the number of dragons on the team before removal is 5, then the dragon in index 4 (the last filled index) should be copied into the dragon spot in index 3. Subsequently, the number of dragons on the team should be updated to 4.

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

Spatial Database Systems Design Implementation And Project Management

Authors: Albert K.W. Yeung, G. Brent Hall

1st Edition

1402053932, 978-1402053931

More Books

Students also viewed these Databases questions

Question

What is linear transformation? Define with example

Answered: 1 week ago