3 Replies - 2289 Views - Last Post: 24 November 2009 - 10:11 PM Rate Topic: -----

#1 sujen07  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 04-October 09

Translate Word Jumble from C++ to VB.Net

Posted 24 November 2009 - 09:29 PM

I came across this word jumble codes from a c++ post in this forum this is the post word jumble in c++ I would like some help for translating this to vb.net here are the codes

#include <iostream>
#include <string>
#include <cstdlib>
#include <ctime>

using namespace std;

int main()
{
	enum fields {WORD, HINT, NUM_FIELDS};
	const int NUM_WORDS = 5;
	const int MAX_GUESSES = 5;
	const string WORDS[NUM_WORDS][NUM_FIELDS] =
	{
	{"wall", "Do you feel you're banging your head against something?"},
	{"glasses", "These might help you see the answer."},
	{"labored", "Going slowly, is it?"},
	{"persistent", "Keep at it."},
	{"jumble", "It's what the game is all about."}
	};

	string guess;
	int points = 0;
	char another;


	do
	{
		system("cls");
		srand(time(0));
		int choice = (rand() % NUM_WORDS);
		string theWord = WORDS[choice][WORD]; // word to guess
		string theHint = WORDS[choice][HINT]; // hint for word

		string jumble = theWord; // jumbled version of word
		int length = jumble.size();

		for (int i=0; i<length; ++i)
		{
			int index1 = (rand() % length);
			int index2 = (rand() % length);
			char temp = jumble[index1];
			jumble[index1] = jumble[index2];
			jumble[index2] = temp;
		}
		cout << "\t\t\tWelcome to Word Jumble!\n\n";
		cout << "Unscramble the letters to make a word.\n";
		cout << "Enter 'hint' for a hint.\n";
		cout << "Enter 'quit' to quit the game.\n\n";
		cout << "The jumble is: " << jumble;
   
		for(int nIndex = 0; nIndex < MAX_GUESSES; nIndex++)
		{
			cout << "\n\nGuess " << nIndex+1 << ": ";
			cin >> guess;

			if (guess == "hint")
			{
				cout << theHint;
				points--; //subtract 1 point
			}//end if
			else if (guess == theWord)
			{
				cout << "\nThat's it! You guessed it!\n";
				points += guess.size(); //points = # of letters in word
				break;
			}//end else if
			else
			{
				cout << "Sorry, that's not it.";
			}//end else
		}//end for
		cout << "\n\nYour Total Points Are: " << points;
		cout << "\n\n\nWould You Like To Play Again? (y/n): ";
		cin  >> another;
	}while(another == 'y' || another == 'Y');

	system("cls");
	cout << "Thanks for playing!";

	return 0;
}//end main



all thanks to the guy who post this :)
thanks alot3

Is This A Good Question/Topic? 0
  • +

Replies To: Translate Word Jumble from C++ to VB.Net

#2 no2pencil  Icon User is offline

  • Admiral Fancy Pants
  • member icon

Reputation: 5363
  • View blog
  • Posts: 27,325
  • Joined: 10-May 07

Re: Translate Word Jumble from C++ to VB.Net

Posted 24 November 2009 - 09:32 PM

View Postsujen07, on 24 Nov, 2009 - 10:29 PM, said:

I would like some help for translating this to vb.net here are the codes

How can we help when you have not started it yet?
Was This Post Helpful? 0
  • +
  • -

#3 sujen07  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 04-October 09

Re: Translate Word Jumble from C++ to VB.Net

Posted 24 November 2009 - 09:48 PM

View Postno2pencil, on 24 Nov, 2009 - 08:32 PM, said:

View Postsujen07, on 24 Nov, 2009 - 10:29 PM, said:

I would like some help for translating this to vb.net here are the codes

How can we help when you have not started it yet?

well i'm studying vb.net and have got no experience in c++ at all, so yeah thats why i'm asking for a little help in translating it
Was This Post Helpful? 0
  • +
  • -

#4 PsychoCoder  Icon User is offline

  • Google.Sucks.Init(true);
  • member icon

Reputation: 1641
  • View blog
  • Posts: 19,853
  • Joined: 26-July 07

Re: Translate Word Jumble from C++ to VB.Net

Posted 24 November 2009 - 10:11 PM

Well we're not going to do the work for you, so I suggest you research what you dont understand in that code (or you can ask here) and start the translation, then when you run into problems we can help.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1