I'm learning c++ and as an exercise with arrays and user input, I'm trying to write a simple poker application.
Since I'm at the begin of this course, all I know about the c++ language is that the execution of the code is demanded to the main()
function. I've write some lines of code that is the base of the final app, it works fine for now. I want to implement a loop to re run the app based on the user input and on a condition that for the scope of the app will be the amount of th fish variable quantity after every execution. How I can achieve this? Another question is about the use of random elements from an array. Is there any good reference where I can learn how to do this?
This is my code:
#include <iostream>
using namespace std;
int main(){
string name;
int bet;
int fish = 100;
char seed[4][10] = {"hearts","clubs","diamonds","spades"};
int cards[9] = {2,3,4,5,6,7,8,9,10};
std::cout << "Welcome in PokerBash! Please enter your name:" <<std::endl;
std::cin >> name;
std::cout << "Your name is " << name <<std::endl;
std::cout << "You have a credit of:" << fish <<std::endl;
std::cout << "Please enter your bet:" <<std::endl;
std::cin >> bet;
std::cout << "Your cards are " << seed[2] << " " << cards[3] << " " << seed[1] << " " << cards[7] <<std::endl;
std::cout << "Your credits after this bet:" << fish - bet <<std::endl;
return 0;
}