Created
June 7, 2022 10:36
-
-
Save aviralgoel/6f56cf2b2efd2d3977eaf38d6453465a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
using namespace std; | |
// Solution #1 (BAD) | |
int IncreaseHealthBy50(int _hp) | |
{ | |
return _hp + 100; | |
} | |
int IncreaseHealthBy60(int _hp) | |
{ | |
return _hp + 60; | |
} | |
// Solution #2 (Bad) | |
int IncreaseHealthBy(int _hp, int value) | |
{ | |
return hp+value; | |
} | |
int main() | |
{ | |
cout << IncreaseHealthBy50(100); | |
cout << IncreaseHealthBy60(200); | |
// Drawback: we have to pass 50 again and again explicitly | |
cout << IncreaseHealthBy(100, 50); | |
cout << IncreaseHealthBy(150, 50); | |
cout << IncreaseHealthBy(200, 50); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment