i'm very much a newbie, so pardon me if i am breaking programmer ettiquette, but could someone debug this, please? i could use a lift after 8+ hours workin on this...
this is
player.h
#ifndef PLAYER_H
#define PLAYER_H
using namespace std;
class player
{
private:
char* name;
int bankroll = 1000;
int bet = 100;
public:
void add_name(char *ip1)
{
name=new char[10]; strcpy(name,ip1);
}
char* getname() {return name;}
int betting(int betRef, int bankrollRef)
{
cout << "Bank Roll: $" << bankrollRef << endl;
cout << "You Bet: $" << betRef << ". " << "You have $" << bankrollRef - betRef << " left.\n";
if (bankrollRef == '0')
{
cout << "\n You're BROKE!";
}
return bankrollRef, betRef;
}
};
#endif
this is my practice.cpp
#include <iostream>
#include <algorithm>
#include "player.h"
using namespace::std;
using std::random_shuffle;
int main()
{
//general directions for a user-friendly interface
cout << "Welcome to the Blackjack Game!\n" << endl;
cout << " Directions:\n" << endl;
cout << " You may ask the dealer to:" << endl;
cout << " (H) Hit \n (S) Stand \n (D) Double Down" << endl;
cout << " (?) Show Deck\n (Q) Quit\n\n" << endl;
cout << "=============================================\n" << endl;
player s1;
cout << endl;
cout << "Please enter your name: ";
cin >> s1.add_name(" ");
cout << "Welcome: " << s1.getname() << endl;
player::betting;
//if statements that responds to user input
// int selection;
//
// if (selection == 'H' || 'h')
// do this
// if (selection == 'S' || 's')
// do this
// if (selection == 'D' || 'd')
// do this
// if (selection == '?')
// do this
// else (selection == 'Q' || 'q')
// {
// break;
// }
//
char cards[13]={'2','3','4','5','6','7','8','9','0','J','Q','K','A'};
char deck [260];
for (int i=0; i< 260; i++)
deck[i] = cards [i % 13];
random_shuffle(deck, deck+260); //researched random shuffle on http://gethelp.devx.com/techtips/cpp_pro/10min/10min1299.asp
random_shuffle(deck, deck+260); //use this function to shuffle again
int selection;
if(selection == '?')
{
for (int i = 0; i < 260; ++i)
cout << deck[i];
system("PAUSE");
}
cin >> selection;
return 0;
}
thank you if you are able to help!