• 10
• 10
• 12
• 12
• 14
• entries
149
510
• views
94849

# Proud and Complete

71 views

Next the world...

Something wonderful happened a few days ago and I'd like to share it. My son Brandon made his first program using C++. I started showing him how to use cin and cout which lead to a discussion about if-then-elses. I gave him a short example and left him alone to play for about a half hour. When I returned he was acting very frustrated and mumbling something like, "It says I have errors and I tried..." So we went over his code line-by-line and found the missing syntax that was causing his very first bug induced fit. [smile] That takes me back to when I was 10. So without further delay, here is Brandon's first program:

int _tmain(int argc, _TCHAR* argv[]){			int game_choice = 0;	cout << "Choose one: \n\n" << "1. Chess\n2. Checkers\n3. Other" << endl;	cin >> game_choice;		if(game_choice == 1)	{		cout << "\nYou are an enlightened intelligent being!!!!\n" << endl;	}	else if(game_choice == 2)	{		cout << "\nYou are A DORK YOU CREEP!!!!\n" << endl;	}	else if(game_choice == 3)	{		cout << "\nRETARDED FROG YOU ARE YES!!!!\n" << endl;	}	else	{		cout << "\nDumb nimwit! uhh I mean does not compute!!!!\n" << endl;	}	return 0;}

Did I mention he's a 3 time chess champion?

Archival tool completed...

In other news I completed the archival tool. It works great! Now I'll need to add loading functions throughout my libraries to access files within the encrypted archive. I've already got textures loading at supa-fast speeds. [smile] Yeah!

Quote:
 Did I mention he's a 3 time chess champion?

I'd never of guessed [wink]

Quote:
 In other news I completed the archival tool.

Congrats - so I guess that thing about the binary search/index worked out well in the end [grin]

Have you got change-detection stuff in your archive? I wrote up a CRCN algorithm to use against storing files for this purpose. It rocked, but I never actually used it for anything [oh]

Jack

Quote:
 so I guess that thing about the binary search/index worked out well in the end
You bet! Thanks for speaking up when you did.
Quote:
 Have you got change-detection stuff in your archive
No it's pretty simple. But that seems like it'd be a great add on for the next version. [smile] What did you have in mind? And how could I use Cyclic Redundancy Check in an archive?

Quote:
 What did you have in mind? And how could I use Cyclic Redundancy Check in an archive?

Baring in mind that I've got some code to do this, but never actually implemented in a (re-)usable component...

My idea was, when creating the archive, to attach a CRC32 or CRC64 to each entry in the header based on each files byte stream. Maybe, although not required an overall CRC32 for the whole data section (minus header).

Such a mechanism offers a few options:

1. When recompiling/rebuilding an archive, you can determine if the actual content of a file has changed.

2. When loading data from the archive you can determine it's validity (e.g. anti-hacking etc..)

Probably some more but I can't remember them right now [smile]. #2 was the big one for my project - hacking the files wasn't difficult, but we wanted to make the game explode (in subtle ways) if they did [wink]

hth
Jack

I like the way your son names his variables. Definitely promising. Beginners always do things like:
int gc;
int gamec;
int game;
int x;

Or similar things. So it's cool he chose a clear name. Also, the comments are funny [smile]

However, if he's really showing interest in programming, I recommend introducing him to python or some similar high level language. It's easier to write clean code in higher-level languages. Additionally, it's easier to make functional programs as well, which is good. A language like C++ typically bores the hell out of beginners, because it takes so long to do interesting things with it.