Okay cool, now those 3 have converted into 5 other errors, all strange and never before seen by my eyes.
Code:
------ Build started: Project: Blackjack, Configuration: Debug Win32 ------
Compiling...
Game.cpp
c:\documents and settings\jcoleman\desktop\blackjack\blackjack\game.cpp(35) : error C2662: 'Player::draw' : cannot convert 'this' pointer from 'const Player' to 'Player &'
Conversion loses qualifiers
c:\documents and settings\jcoleman\desktop\blackjack\blackjack\game.cpp(36) : error C2662: 'Game::get_hand_value' : cannot convert 'this' pointer from 'const Game' to 'Game &'
Conversion loses qualifiers
c:\documents and settings\jcoleman\desktop\blackjack\blackjack\game.cpp(44) : error C2662: 'Game::get_hand_value' : cannot convert 'this' pointer from 'const Game' to 'Game &'
Conversion loses qualifiers
c:\documents and settings\jcoleman\desktop\blackjack\blackjack\game.cpp(44) : error C2662: 'Game::get_hand_value' : cannot convert 'this' pointer from 'const Game' to 'Game &'
Conversion loses qualifiers
c:\documents and settings\jcoleman\desktop\blackjack\blackjack\game.cpp(62) : error C2662: 'Data::read_numeric_data' : cannot convert 'this' pointer from 'const Card' to 'Data &'
Conversion loses qualifiers
Build log was saved at "file://c:\Documents and Settings\jcoleman\Desktop\Blackjack\Blackjack\Debug\BuildLog.htm"
Blackjack - 5 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
I think my code is how you were saying before.
Code:
#ifndef GAME_H
#define GAME_H
#include "Dealer.h"
#include <vector>
#include "IO.H"
#include "Player.h"
class Game
{
public:
Game(){}
void play_game(void);
private:
int blackjack(int result) const;
int get_hand_value(const std::vector<Card> & hand);
Player player;
Dealer dealer;
Deck deck;
text_menu tmenu;
IO io;
};
#endif
Code:
#include "stdafx.h"
#include <iostream>
#include "Game.h"
void Game::play_game()
{
//shuffle the deck first
dealer.shuffle_deck(deck);
//draw cards for players
dealer.draw(deck, 1);
player.draw(deck, 2);
//initialize the gameloop
int gameloop = 1;
//initialize output
io.init_output(tmenu);
//start gameloop
while(gameloop != 0)
{
//update
io.update_output(2, dealer.hand->read_cards());
io.update_output(6, player.hand->read_cards());
//display
io.display_output();
gameloop = blackjack(io.get_input());
//clear
io.clear_screen();
}
}
int Game::blackjack(int result) const
{
if (result == 1)
{
player.draw(deck, 1);
if (get_hand_value(player.hand->card_list) > 21)
{
return 0;
}
else { return 1; }
}
else if (result == 2)
{
if(get_hand_value(player.hand->card_list ) > get_hand_value(dealer.hand->card_list))
{
return 0;
}
else { return 0; }
}
else if (result == 3)
{
return 0;
}
return 1;
}
int Game::get_hand_value(const vector<Card> & hand)
{
int sum = 0;
for (unsigned int loop = 0; loop < hand.size(); loop++)
{
sum += hand[loop].read_numeric_data();
}
return sum;
}