Subscribe to pbivens85's Blog        RSS Feed
-----

hangman

Icon Leave Comment
I am developing a hangman game using c++. here is my code so far.
#include <iostream>

using namespace std;

class hangman
{
	char word[20];
	char guess[20];
public:
	void graph_one();
	void graph_two();
	void graph_three();
	void graph_four();
	void graph_five();
	void graph_six();
	void graph_seven();
	void graph_eight();
	void graph_nine();
	void input_word();
	void input_guess();
};

void hangman::input_guess()
{
	cout << "Enter guess: ";
	cin >> guess;
	cout << endl;
}

void hangman::input_word()
{
	cout << "Enter word: ";
	cin >> word;
	cout << endl;
}

void hangman::graph_one()
{
	cout << endl;
	cout << " ---- " << endl;
	cout << " |  | " << endl;
	cout << " |    " << endl;
	cout << " |    " << endl;
	cout << " |    " << endl;
	cout << " |    " << endl;
	cout << "------" << endl;
	cout << endl;
}

void hangman::graph_two()
{
	cout << endl;
	cout << " ---- " << endl;
	cout << " |  | " << endl;
	cout << " |  O  " << endl;
	cout << " |    " << endl;
	cout << " |    " << endl;
	cout << " |    " << endl;
	cout << "------" << endl;
	cout << endl;
}

void hangman::graph_three()
{
	cout << endl;
	cout << " ---- " << endl;
	cout << " |  | " << endl;
	cout << " |  O  " << endl;
	cout << " |  |  " << endl;
	cout << " |    " << endl;
	cout << " |    " << endl;
	cout << "------" << endl;
	cout << endl;
}

void hangman::graph_four()
{
	cout << endl;
	cout << " ---- " << endl;
	cout << " |  | " << endl;
	cout << " |  O  " << endl;
	cout << " | -|  " << endl;
	cout << " |    " << endl;
	cout << " |    " << endl;
	cout << "------" << endl;
	cout << endl;
}

void hangman::graph_five()
{
	cout << endl;
	cout << " ---- " << endl;
	cout << " |  | " << endl;
	cout << " |  O  " << endl;
	cout << " | -|-  " << endl;
	cout << " |    " << endl;
	cout << " |    " << endl;
	cout << "------" << endl;
	cout << endl;
}

void hangman::graph_six()
{
	cout << endl;
	cout << " ---- " << endl;
	cout << " |  | " << endl;
	cout << " |  O  " << endl;
	cout << " | -|-  " << endl;
	cout << " |  |  " << endl;
	cout << " |    " << endl;
	cout << "------" << endl;
	cout << endl;
}

void hangman::graph_seven()
{
	cout << endl;
	cout << " ---- " << endl;
	cout << " |  | " << endl;
	cout << " |  O  " << endl;
	cout << " | -|-  " << endl;
	cout << " |  |  " << endl;
	cout << " |  |  " << endl;
	cout << "------" << endl;
	cout << endl;
}

void hangman::graph_eight()
{
	cout << endl;
	cout << " ---- " << endl;
	cout << " |  | " << endl;
	cout << " |  O  " << endl;
	cout << " | -|-  " << endl;
	cout << " |  |  " << endl;
	cout << " | -|  " << endl;
	cout << "------" << endl;
	cout << endl;
}

void hangman::graph_nine()
{
	cout << endl;
	cout << " ---- " << endl;
	cout << " |  | " << endl;
	cout << " |  O  " << endl;
	cout << " | -|-  " << endl;
	cout << " |  |  " << endl;
	cout << " | -|-  " << endl;
	cout << "------" << endl;
	cout << endl;
}

int main()
{
	hangman hang;
	hang.input_word();
	hang.input_guess();
	
	int num = 7;
	
	switch (num)
	{
	case 1:
		hang.graph_one();
		break;
	case 2:
		hang.graph_two();
		break;
	case 3:
		hang.graph_three();
		break;
	case 4:
		hang.graph_four();
		break;
	case 5:
		hang.graph_five();
		break;
	case 6:
		hang.graph_six();
		break;
	case 7:
		hang.graph_seven();
		break;
	case 8:
		hang.graph_eight();
		break;
	case 9:
		hang.graph_nine();
		break;
	}

	system("pause");
	return 0;
}

0 Comments On This Entry

 

Trackbacks for this entry [ Trackback URL ]

There are no Trackbacks for this entry

June 2018

S M T W T F S
     12
3456789
10111213141516
17 18 1920212223
24252627282930

Tags

    Recent Entries

    Recent Comments

    Search My Blog

    0 user(s) viewing

    0 Guests
    0 member(s)
    0 anonymous member(s)

    Categories