Click here to Skip to main content
15,891,409 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Specify a void function named experienced_Player (). The function will accept
two Player type objects and will control which of the two players has the most experience.
Checks will be made and the following messages should be printed:
• 'First Player is stronger'
• 'Second Player is stronger'
• 'Tie'

What I have tried:

ive tried to do the function void experienced_player but i cant
Posted
Updated 16-Mar-20 15:42pm
v2

1 solution

You could use this :
C++
void experienced_Player( Player & p1, Player & p2 )
{
    strength_t s1 = p1.GetStrength();
    strength_t s2 = p2.GetStrength();
    if( s1 > s2 )
          // player one is stronger
    else if( s1 < s2 )
          // player two is stronger
    else
          // they are equal strength
}
Now you need to define a type that contains the strength, the strength_t, and write a method for the player object that returns its strength. You also need to add the code to print the messages.
 
Share this answer
 
v2
Comments
CPallini 17-Mar-20 3:18am    
Could be useful to return an int, couldn't be?
My 5.
phil.o 17-Mar-20 5:24am    
A void function is explicitly required :)
CPallini 17-Mar-20 5:36am    
Oooops!
What a madness, neverthless. :-)
Thank you.
LATIF Ι.Κ 17-Mar-20 17:40pm    
thank you very much to all <3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900