Good afternoon. I am make a simple super hero battle code for fun. I have a function and the main with two int variables. The variables(superheros) get points based on strikes I programmed in. However, the variable with the most points adds correct Exp: 4+3+2 = 9. But the variable with lesser points does not exp: 2+6+9 = 269. Any Advice?
So... it needs to return an int. I have tried 0, and return (super1, super2), and return super1, super2. I get different answers, all have issues with the second number. The closest I got was the second number is being multiplied by 10. Updated code below. Thanks for the insight.
#include <iostream>
usingnamespace std;
int superBattle(int super1, int super2)
{
if(super1>super2)
{
cout<<"Batman wins! "<< super1 << " to " << super2;
}
else
{
cout<<"Arrow wins! " << super2 << " to " << super1;
}
return 0;
}
int main()
{
constint punch = 3;
constint kick = 4;
constint takedown = 10;
constint knockOut = 50;
constint block = 1;
int Batman = 0;
int Arrow = 0;
cout<<"\tWe find our heroes in a dark alley that lies in the center of Starling City.\n";
cout<<"Normally this time of night the streets are rampant with crooks, murderers, and those who seek to do harm.\n";
cout<<"Tonight however even the scum of the city hides. Two of the greatest heroes are in a heated battle... Against each other!\n\n\n\n";
cout<<"Arrow you're out of line!\n";
cout<<"Go Back to Gotham Bat!\n";
cout<<"Not without you Arrow.\n\n\n\n";
cout<<"Batman strikes first, using he's training and experience.\n";
cout<<"An upper cut to Arrow's chin, followed by a kick to his gut! Giving the opportunity for a leg sweep. Arrow is down.\n\n\n\n";
Batman = Batman + punch + kick + takedown;
cout<<"Give up Arrow, and come with me.\n";
cout<<"No way Bat! I saved your city!\n\n\n\n";
cout<<"But The Batman isn't the only one that has training. Arrow moves fast with a double roundhouse kick.\n";
cout<<"Arrow sees the opportunity for a tackle and takes it. The Bat is down.\n";
Arrow = Arrow + kick + kick + takedown + block + block;
cout<<"As Both Heroes stand in the alley, out of breath, on this unusually hot night. The verbal battle begins.\n\n\n";
cout<<"You had no right! yells the Bat. You killed him, In my city.\n";
cout<<"He was going to destroy your city Bat!\n";
cout<<"I had it under control, the toxic gas was already contained, and the bomb disarmed.\n";
cout<<"So you wanted to let him free to do it again... is that it Bat. Keep you employed!?\n\n";
cout<<"You think that is why I do this, uh Arrow!\n";
cout<<"You watch your tongue Oliver!\n\n";
cout<<"You don't scare me Bat!\n";
cout<<"I SHOULD! I am done wasting time!\n\n\n";
Batman = Batman +punch + punch + kick + punch;
Arrow = Arrow + block + block + punch;
cout<<"The Battle rages, punches and kicks are thrown and blocked. Both heroes have met there equal.\n\n";
Arrow = Arrow + punch + kick + block + takedown;
Batman =Batman + punch + knockOut;
cout<<"Suddenly there is silence. One hero stands and another lies on the ground.\n";
cout<<"The shadows hide the victor. Until the red and blue police lights cast the shadows out.\n";
cout<<"Revealing ...\n\n";
cout<<superBattle(Batman, Arrow);
return 0;
}
False :) It does not need to return anything, because you're simply printing statements from the function. Nothing needs to be returned to the caller (main).