BetaWar's Profile User Rating: *****

Reputation: 1147 Grandmaster
Group:
Moderators
Active Posts:
7,150 (2.45 per day)
Joined:
07-September 06
Profile Views:
56,746
Last Active:
User is offline Yesterday, 04:40 PM
Currently:
Offline

Previous Fields

Country:
US
OS Preference:
Windows
Favorite Browser:
Chrome
Favorite Processor:
Who Cares
Favorite Gaming Platform:
XBox
Your Car:
Who Cares
Dream Kudos:
1600

Latest Visitors

Icon   BetaWar has not set their status

Posts I've Made

  1. In Topic: F2P games you play

    Posted 26 Aug 2014

    I recently tripped across Path of Exile on steam. It looked fun and I got it, it is actually pretty good. Very Diablo 2-esque (except, in 3D)
  2. In Topic: If ... AndAlso statements not working as expected

    Posted 22 Aug 2014

    Moved to VB.net since it isn't a tutorial.
  3. In Topic: std::list::iterator behaving inconsistently

    Posted 18 Aug 2014

    That's an interesting thing about iterators. There isn't any guarantee that a dereferenced iterator will be 0 (which is what you are currently doing in both of your checks). What you should do instead is if(findIter == people.end()) at which point the item wasn't found in the list, otherwise it was found in the list.

    Here's std::find's documentation:
    http://www.cplusplus...algorithm/find/
  4. In Topic: String not being declared

    Posted 18 Aug 2014

    So, since this is C++, you could do a number of things. The first thing to keep in mind is that C++ doesn't allow you to concatenate a string and a number together, it doesn't know how to deal with that unless you tell it. You can use a stringstream to output your string and numbers to a buffer and then read it as a string from that (which is probably what you want to do with lines 12 through 15).

    Then, the using namespace std; is useful for simplifying what you need to type, but not necessarily good in the long run (as, if you have your own classes, you can get some confusion with name overlaps at that point). However, in this case it really doesn't matter, so do what you feel more comfortable with.

    In C++, std::string (or string) is in fact all lower case, so that's correct.

    If you comment out lines 13-15 (leaving line 12 alone) does it compile then?

    <edit>
    Arduino uses C# now? That's interesting... You can disregard my post :)
    </edit>
  5. In Topic: Pls help me my with Tic Tac Toe game [c++]

    Posted 15 Aug 2014

    Lets start with the easiest thing first: formatting. If you format your code consistently it will be a lot easier to tell what is going on and what is wrong. Many editors will even do this for you automatically making it something very easy to accomplish.

    #include <iostream>
    #include <string>
    using namespace std;
    class TicTacToe
    {
    	private:
    		char table[3][3]; 
    	public:
    		TicTacToe() {}
    		void setTable() 
    		{
    			int n = 1;
    			for(int i = 0; i < 3; i++)
    			{ 
    				for(int j = 0; j < 3; j++)
    				{ 
    					table[i][j] = '0' + n;
    					n++; 
    				}
    			}
    		}
    
    
    		void printTable()
    		{ 
    			for(int i = 0; i < 3; i++)
    			{ 
    				for(int j = 0; j < 3; j++) 
    					if(j < 2) 
    					{
    						cout << table[i][j] << "|"; 
    					}
    					else 
    					{
    						cout << table[i][j] << endl; 
    					}
    				if(i < 2) 
    				{
    					cout << "-+-+-\n"; 
    				}
    			}
    		} 
    		void playerMove(char num, char player)
    		{
    			bool wrongMove = true;
    			for(int i = 0; i < 3; i++)
    			{ 
    				for(int j = 0; j < 3; j++) 
    				{
    					if(table[i][j] == num)
    					{
    						table[i][j] = player; wrongMove = false; 
    					}
    				}
    			}
    			if(wrongMove == true) 
    			{
    				cout << "Wrong move!\n";
    			}
    		} 
    		bool checkWinner(char player, bool gameOver) 
    		{
    			for(int i = 0; i < 3; i++)
    				if(table[i][0] == table[i][1] && table[i][1] == table[i][2]) 
    					gameOver = true;
    
    			for(int i = 0; i < 3; i++)
    				if(table[0][i] == table[1][i] && table[1][i] == table[2][i]) 
    					gameOver = true;
    
    			if(table[0][0] == table[1][1] && table[1][1] == table[2][2])
    				gameOver=true;
    
    			if(table[0][2] == table[1][1] && table[1][1] == table[2][0]) 
    				gameOver = true;
    
    			if(gameOver == true) 
    			{
    				cout << "Player " << player << " wins!\n\n"; 
    			}
    			return gameOver; 
    		}
    		bool checkDraw(bool gameOver)
    		{ 
    			int n = 1, count = 0; 
    			for(int i = 0; i < 3; i++) 
    			{ 
    
    				for(int j = 0; j < 3; j++) 
    				{ 
    					if(table[i][j] == '0'+n) 
    					{
    						count++; 
    					}
    					n++; 
    				}
    
    			}
    			if(count < 1) 
    			{
    				cout << "It's a draw!\n\n";
    				gameOver = true; 
    			}
    			return gameOver; 
    		};  
    
    
    
    		int main()
    		{ 
    			bool done = false, gameOver = false; 
    			char player = 'O', num; 
    			TicTacToe myGame;
    			myGame.setTable(); 
    			do 
    			{ 
    				if(player == 'X') 
    				{
    					player = 'O'; 
    				} 
    				else 
    				{
    					player = 'X';
    				}
    				myGame.printTable();
    				cout << "Player \"" << player << "\" turn or (q) to quit> ";
    				cin >> num;
    				cout << "\n";
    				if(num == 'q')
    				{
    					cout << "Goodbye!...\n"; 
    					break; 
    				} 
    				myGame.playerMove(num, player);
    				gameOver = myGame.checkWinner(player, gameOver); 
    				gameOver = myGame.checkDraw(gameOver); 
    				if(gameOver == true)
    				{	
    					myGame.setTable(); 
    					gameOver = false; 
    				}
    			}
    			while(!done);  
    			system("pause");
    			return 0; 
    
    
    


    Now, notice how you have functions that just keep getting indented and aren't finishing at column zero? That indicates that you have mismatched braces somewhere.

    Lets start by having you correct that.

My Information

Member Title:
#include "soul.h"
Age:
23 years old
Birthday:
September 6, 1990
Gender:
Location:
Your mind
Interests:
Video games, programming, school.
Full Name:
James Blades
Years Programming:
5+
Programming Languages:
JavaScript, Java, C, C++, Actionscript 2, Actionscript 3, PHP 4, PHP 5, Python 2.6, Perl

Contact Information

E-mail:
Private
Website URL:
Website URL  http://www.reigninggames.com
LinkedIn:
http://www.linkedin.com/in/jwkblades

Comments

Page 1 of 1
  1. Photo

    raghav.naganathan Icon

    25 Feb 2013 - 04:43
    Congrats on the 900 :) Perfect square :)
  2. Photo

    Nseiki102 Icon

    07 Oct 2011 - 08:59
    Thank You for your help. I greatly appreciate it.
  3. Photo

    BetaWar Icon

    15 Feb 2011 - 09:17
    No problem. I love JavaScript so it isn't anything terribly difficult. The hardest part is to come up with challenges that will get people interested and not scare everyone away until we at least are a bit more known :)
  4. Photo

    Dormilich Icon

    15 Feb 2011 - 00:42
    thanks for managing the JavaScript competition.
    best wishes, Dormi
  5. Photo

    Theaegd Icon

    28 Mar 2010 - 11:56
    I <3 opera
  6. Photo

    BetaWar Icon

    21 Feb 2010 - 11:21
    I think there are a few people who like IE, but we are the minority. I use it because I have grown up with it, it acts the most as I would expect it to (out of the major browsers) and I have grown accustom to its little quirks. Everyone talks about building things for FF then hacking for IE, but I find that Opera, IE, Chrome, and Sarafi normally work very close to the same, and FF is the outlier.
  7. Photo

    -=m0n1k3r=- Icon

    20 Feb 2010 - 21:11
    Serious Question(s): Are you the only user who prefers IE over all of the other browsers? I haven't seen anyone else with that marked...
    Also, why do you prefer it?
Page 1 of 1