#include <iostream> // cin, cout
#include <string> // string type
#include <vector>
#include <ctime> // time
#include <cctype>

using namespace std;

int main( void ) 
{
#if 0
	// <namespace>::<object>
	int a = 100;
	float f = 34.1;
	bool why = true;
	char c = 'X';

	// output to console

	cout << "Hello World!" << endl;

	//C
	//printf("%d, %f, %c, %s\n", a, f, c, "Hello World" );
	cout << a << ", " << f << ", " << c << ", " << why << " Hello World" << endl;

	// get user input

	int number;
	string word;

	//C
	//scanf("%d", &number);

	//C++
	cout << "Enter a number: ";
	cin >> number;
	cout << "Enter a word: ";
	cin >> word;
	cout << "You entered number " << number << " and a word " << word << endl;
#endif
	//String type
	string astring;
	astring = "I am a string";
	string bstring;
	bstring = "I am another string";
	// Get string legnth
	cout << "astring has " << astring.length() << " letters." << endl;
	// Append a string or concatinate
	astring = astring + ".";
	bstring += ".";
	cout << "astring is " << astring << endl <<  "bstring is " << bstring << endl;
	cout << astring + bstring << endl;
	// Compare two strings
	if( astring == bstring )
		cout << "astring is equal to bstring" << endl;
	else
		cout << "astring is not equal to bstring" << endl;

	// List of objects
	//C
    //char *wordList[] = { "apple", "pear", "peach", "banana" };
    //int wordCount = sizeof(wordList) / sizeof(wordList[0]);

	// vector: generic type, template
	// vector<type>
	vector<string> wordlist;
	wordlist.push_back( "apple" );
	wordlist.push_back( "pear" );
	wordlist.push_back( "peach" );
	wordlist.push_back( "banana" );

	cout << "We have " << wordlist.size() << " fruits" << endl;

	for( int i=0; i < wordlist.size(); i++ ) {
		cout << "the " << i << "th word: " << wordlist[i] << endl;
	}

	// random number generation
	srand( (unsigned int) time(0) );
	cout << "a random word is " <<  wordlist[ rand() % wordlist.size() ] << endl;


	// Define constant
	//C
	// #define MAX_WRONG_CNT 6

	const int MAX_WRONG_CNT = 6;

	system("pause");
}