C++ Programming help needed
C++ Programming help needed. Adjusting following code in attached file.
ATTACHMENT PREVIEW Download attachmentWeek 6 AssignmentsWith SF_ver3, we give the targets a chance to fght back. For each game turn, a±ter the player throws asnowball, any remaining targets get to throw a snowball back. So, i± you have three targets, the player hasthree snowballs thrown back at him or her. As be±ore, once a target is hit, it is removed ±rom the grid. Thisalso means that target cannot throw a snowball. The player can choose to stay where he or she is or move atthe end o± each turn. Here are the victory conditions.I± all the targets have been hit and the player has not been hit at the end o± a turn, the player wins.I± at least one target remains on the grid and the player has been hit, the player loses.I± all the targets and the player have been hit at the end o± a turn, it is a tie.I± all the snowballs are thrown and none o± the three conditions above has occurred, the game is atie.The targets choose where to throw the snowball at random. The targets and the player are on di²erent grids,but the grids have the same number o± rows and columns.Here is the base code.// Week 6 Assignment-1// Description: Snowball Fight – version 3//———————————-//**begin #include fles************#include<iostream>// provides access to cin and cout#include<array>// provides access to std::array#include<time.h>// provides access to time() ±or srand()//–end o± #include fles———–//———————————-usingnamespacestd;//———————————-//**begin global constants**********// defne coordinate structurestructCoords{intx;inty;};// defne a struct o± the targetstructMyStruct{intID;// — Identifcation number o± the targetCoordsposition;// — position o± targetintdist;// — distance between target and snowball hitboolhit;// — ³ag indicating target has been hit};constintgridSize = 5;// const grid size (i.e. 5×5 grid constant is 5)constintturns = 20;// const number o± turnsconstinttargetCount = 3;// number o± targets//–end o± global constants———//———————————-//**begin ±unction prototypes*******intthrowSnowball(Coordsp,MyStruct&Target);voidmoveTarget(MyStruct&Target);//–end o± ±unction prototypes——//———————————-//**begin main program**************intmain(){// initializationsrand(time(NULL));

View the AnswerWeek 6 AssignmentsboolallHit =false;inthitCount = 0;// number of hits.intdist = 0;// distance of missCoordssnowballPos;// position of snowball hitarray<MyStruct, targetCount> Targets;// Initialize targetsintidNum = 0;for(auto&T: Targets)//**Error 1: add the “&”{T.ID = idNum++;// set identiFcation number// set target at random locationT.position.x = rand()%gridSize;T.position.y = rand()%gridSize;T.hit =false;// set target hit ±ag to default: false}// loop for the speciFed number of turnsfor(inti = 0; i < turns; i++){//get x and y position for the snowball from playercout <<“column? “;cin >> snowballPos.x;cout <<“row?”;cin >> snowballPos.y;// throw snow ball (see instructions for details)for(auto&T: Targets){if(!T.hit){// check for hit or missdist = throwSnowball(snowballPos, T);// report resultsswitch(dist){case0:cout <<“***SPLAT*** You hit target “<< T.ID <<“!”<< endl;hitCount++;break;case1:cout <<“target “<< T.ID <<“: Way too close!”<< endl;break;case2:cout <<“target “<< T.ID <<“: I heard it hit.”<< endl;break;default:cout <<“target “<< T.ID <<“: Missed by a mile.”<< endl;break;}//target moves (see instruction for detailsif(!T.hit) moveTarget(T);}}if(hitCount == 3){allHit =true;break;}cout <<“—Next Turn—“<< endl;}// end of loop// report score (number of hits vs turns)if(allHit) cout <<“All targets have been hit!Great job!”<< endl;elsecout <<“You had “<< hitCount <<” hits out of “<< turns <<” throws.”<< endl;cin.get();// Wait for user input to close program when debugging.cin.get();return0;}//–end of main program————-//———————————-
