Creating the Roman Commander Game - C++

While jumping around in the clouds of code city, you happen to come across the Emperor of Rome. He is desperately in need of a commander to lead an attack against the Germanian Hordes. Will you accept the challenge?

And, of course you, seeing this as an excellent opportunity to work on your new skills, including random numbers, while loops, do while loops, if statements, switch statements, and the conditional operator, accept.

Type the following code into your compiler’s source code editor and try it out. Think about each of the control statements in the code. Can you read them as though they were in English? If not, you will be able to very soon.

Output:

em>Welcome Adventurer, what is your name?
Marcus
Well, Marcus welcome to the Roman Commander Game.
You are the commander of the Roman Army attacking Germania.
You have 50 archers, 25 catapults, and 100 swordsmen.
Germania has 61 archers, 50 catapults, and 52 swordsmen.
[1] Send Archers
[2] Send Catapults
[3] Send Swordsmen
[4] Go Fight
1
How many archers would you like to send?
50
[1] Send Catapults
[2] Send Swordsmen
[3] Go Fight
1
How many catapults would you like to send?
25
[1] Send Swordsmen
[2] Go Fight
1
How many swordsmen would you like to send?
100
[1] Go Fight
1

Entering Battle...
It was a long battle. 100 archers died.
52 catapults died.
183 swordsmen died.
You lost. Try again next time.

All rights reserved © 2020 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

C++ Topics