You all can reply and post your best programs (the file, not the code lol)
heres my semester project (im a first year programmer in highschool, be nice :))
some input would be nice, criticize it if you want to :(
but by all means, praise me :D
Paro
Printable View
You all can reply and post your best programs (the file, not the code lol)
heres my semester project (im a first year programmer in highschool, be nice :))
some input would be nice, criticize it if you want to :(
but by all means, praise me :D
Paro
here is my slot machine program, its a little more advanced than the one on this website that someone posted, but sorry, the code doesnt have any documentation so it will be a b*tch to read :(
many downloads but no feedback :( *sigh*
man thats kindo f nice. putting so many features into one little program.and only using one .cpp file. very nice indeed. =)
thanks, i encountered many problems in doing that, because i made so many functions instead of shoving it all into the main program...
but thanks for feedback :D
oh hey pero do you know how to make windows app thru c++ i know it's possible i just don't know how. i think its winmain something
hey pero, I like your stuff! for one year of high school its not bad! ;)
To guyondrugs, :rolleyes: it depends on what compiler you are using. If you are using a windows compiler, you create a win32 project and use windows api programming. There's various tutorials on the web. There's some under the directory section of cprogramming.com, too.
to xterria: actually ive only had 1 semester LOL, im on my seconds semester right now :D
to drugguy: it would be way easier for you if you use MSVS because thats what i use and i could probably help
oh aiight thanks x. and pero...man they only program i can use is this free win 32 compiler i got. i don't wanna cheat the companys by getting there program inwhich i was suppose to pay for.
With MFC creating windows and various controls is extremely easy (in MSVC++)
I'll be in highschool next year, and so far i've created tictactoe, connect4, battleship, and now I'm working on an OOP version of the battleship game, which is proving to be much more difficult then I had expected.
for these games did you use Win32 Console Application to make tic-tac-toe and that? cuz im thinking, in console you cant click anything, so you would have to ask the user which position to choose and he/she would input a number which corresponds to a position...
and yes battleship would be REALLY hard to do i think, i cant even think where to start lol :)
good job
Well, when I first started programming.. (in JavaScript) I came across a Battleship game.. and it blew my mind.. the source was much too long for me to comprehend.
But now, Its getting easier with each passing program. All the games were done in console, I think they're on my FTP under '/programs/' if you want to see.
It would be quite trivial to make tictactoe an MFC application. (eg, a real window, mouse useage)
that would be incredible, you should head over to the gamer section of the forums and maybe you could get some info on how to have a GUI and stuff like that (i know absolutely nothing about it :))
very nice slot machine... you should verify good input for a bet though. If you enter a letter, the program bottoms out. Also, what if the user wants to quit? ;)
Very nice though. I am impressed.
i never did figure out how to stop it from screwing up when you enter a letter... but yea i could ask if you wanted to stop, and at school i use the '\b' function so it looked like they were rolling (the numbers) but i must repeat that i dont have MSVC++ at home yet so i cant do anything about it til i go back to school :D
do YOU know how to make it so when it wants an integer you can have an error proof against letters? would be nice to know hehe
cout << "Enter your bet->";
cin >> bet;
while (cin.fail())
{
cout << "Invalid input, please restate->";
cin >> bet;
}
Should catch the program before it 'bottoms out'; I think :)
I should elaborate.. if what the user enters is not compatable with the variable type in which it is to be stored.. you'll get that unexpected behavior.
Someone should correct me on this If I'm wrong :)
>>>Someone should correct me on this If I'm wrong
You aren't....
good job.
cool, im going to put that in there when i make my next proggy
dont say "proggy" makes you sound like an AOLER...Quote:
Originally posted by Paro
cool, im going to put that in there when i make my next proggy
PROGGY PROGGY LOOK AT ME IM SAYING PROGGY
IM SORRY I CANT HELP IT
hi paro, yes you did a pretty good job for a first semester project. one thing that i would have liked you to have in the project, however, was to return to the main menu rather than quit the entire program after choosing and running a menu topic. then maybe you could have the option to quit the program from the main menu. another thing you could do for fun, which i think would be really cool, would be to show the spinning-effect of a slot machine on those numbers. that may be a little tough but it's possible. i didn't take a good look at your source but one way i can think of doing this is go ahead and first come up with a random sequence of numbers, then store them in an array. then you could output this initial array to the console, then increment each number, then make use of the '/r' (i think) escape sequence to be able to return to the beginning of the same line you just outputted and overwrite with the new array. of course everytime you increment each number in the array you would have to make sure they restart to 1 once they increment past 8. you could use some time delay to show the effect of the spinning numbers slowing down and finally make them stop and output the resulting array (you could implement a simple time delay with an empty for loop; and you would have to have the time delay periodically shorten to show the slowing down of "spinning"). note that this will yield "random" results since you initialize an array with "random" values, make them "spin" for some fixed amount of time and this will in turn yield your "random" result everytime.
i don't know, just an idea if you're interested; but none the less great job and keep up the good work!
actually i'm forgetting how a slot machine actually works. you don't need to slow down the "spinning" of the numbers. you just let them "spin" the same speed; but what you would need to do is stop a number from spinning one by one starting from the left.
I would have 5 million dollars without interest if I saved all my money for a hundred years! Wow... I better get started after buying some more mattresses to stuff my money into. ;)
skyline:
actually, it isnt that hard i can do it, and i can make it so it slows down... but one thing i cant do is make it so it spins and then you can hit a button so it stops... but yea, ill make it next week when i come back to school, or if you want i can modift my cpp file so it does it, but i cant compile it til i go back to school :(
>Someone should correct me on this If I'm wrong
Not wrong, but could be better. How about this?
Why test for whether or not cin failed when your if..else statement can do it for you?Code:if ( cin>>bet ) {
// It worked, test for correct bet values
// and play the game
}
else {
// Didn't work, panic (but not really)
-Prelude
nice programs paro :)
actually, for simplicity and also since a slot machine doesn't do it anyway, we don't have to include the slowing down of "spinning". we just stop each number from "spinning" one by one. also, we shouldn't require the user hitting the button to make each number stop anyway since with a slot machine we just pull the lever and the machine stops the numbers by itself (although giving the user the ability to stop the numbers him/herself would be kind of a cool idea as well, but as you state you can't do it at the moment; but later on you can check out multi-threaded programming which will give you the ability to do that).Quote:
Originally posted by Paro
skyline:
actually, it isnt that hard i can do it, and i can make it so it slows down... but one thing i cant do is make it so it spins and then you can hit a button so it stops... but yea, ill make it next week when i come back to school, or if you want i can modift my cpp file so it does it, but i cant compile it til i go back to school :(
you can't compile till you get back to school? there are a lot of free compilers you can obtain and install (on your home pc) that are available on the net. go here for a windows version of emacs along with gcc, g++, and more...
file attached is the slot machine that "spins" the numbers (using your existing code), this is just as an example you could use for some help (i used an empty for loop to delay time, i think you would usually want to make a library call of some sort since using a empty for loop for delaying time will vary from machine to machine).
also, i got a "666" string once that deducted half my points; but also awarded me for a 3 of a kind!
[edited]
added zip instead containing an .exe
[/edited]
Nice Program Paro. One problem with the Allowence program tho... your math is off :-(. Say I enter $5.00 a week it is mathemeitically impossible for me to get 260.71 a year. You should take my weekly allowence and multiply by 52 to get the yearly amount. That should not give me a decimal number. The same problem with Centuries, and Millenium. Good program but check your math.
Isometric
That math problem may be because floats and doubles are approximations, and you gotta be careful when you use them. Theres a way to make them more accurate, I think the command is something to the tune of _asm finite. I don't use floats often because they cause problems.
You might want to correct a little bug. If you enter any other char but integers your program enters a huge loop. You might want to enter something that will tell it to crash or return something saying its not numbers the person entered. If i knew how I would tell you hehe. But apart from that its a neat little thing you made there.
to fix the math replace the calculations for the allowance with this:
also you should not call main from with in your program. Its better to put the whole main function in a while statement.Code:day= (allowance/7.0);
second= (allowance/7.0/24.0/60.0/60.0);
minute= (day/24.0/60.0);
monthly = (allowance*4);
yearly = (allowance*52);
decade = (yearly*10);
hourly = (allowance/7.0/24.0);
century = (yearly*100);
mil = (century*10);
isometric:
really? i shouldn't call the main function from within it? why? is it bad for the computer or something... or is it slower? hmm weird...
Nothing like that only that its bad style and for some reason it constitutes a error on Borland 5.2 (standard) so it has to have some negative effect.
prelude:
an easier way to make it spin is this:
for (int p = 1; p<=1000; ++p)
{
slot1 = rand() % (HIGH - LOW + 1) + LOW;
cout<<slot1<<" ";
slot1 = rand() % (HIGH - LOW + 1) + LOW;
cout<<slot1<<" ";
slot1 = rand() % (HIGH - LOW + 1) + LOW;
cout<<slot1<<" ";
slot1 = rand() % (HIGH - LOW + 1) + LOW;
cout<<slot1<<" ";
slot1 = rand() % (HIGH - LOW + 1) + LOW;
cout<<slot1;
cout<<'\b'<<'\b'<<'\b'<<'\b'<<'\b'<<'\b'<<'\b'<<'\ b'<<'\b';
}
cout<<endl<<endl;
and that should make them look like they are spinning 1000 times then stopping, i could put a delay in there liek Sleep(10) or something small, and then increase the sleep so it appears to be slowing...
maybe you could change my code and put that in there somewhere hehe :D
:confused:
MrJake:
someone had a similar feedback saying that if you enter a char it will do an endless loop...
yea im aware of it and no one in my part of the class could figure out how at the time, this was last semester and i didnt know that you could do cin.fail() and stuff like that...
they were the only programs i had with me (on a floppy) and they were pretty good so i put em up :D
but if you could fix the continuous loop be my guest i gave you the code :D
thanks
I remember those innocent days of programming...:p
HOLY BAJEEBAZ!!!
i was just looking at the download count of my zip files, and the 2 together have 84 downloads!!!!!!!
i have a question:
how would i make a header file out of this:
it would be much easier than copying and pasting it every time i make a program that uses it no? :DQuote:
void clrscr()
{
COORD coordScreen = { 0, 0 };
DWORD cCharsWritten;
CONSOLE_SCREEN_BUFFER_INFO csbi;
DWORD dwConSize;
HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
GetConsoleScreenBufferInfo(hConsole, &csbi);
dwConSize = csbi.dwSize.X * csbi.dwSize.Y;
FillConsoleOutputCharacter(hConsole, TEXT(' '), dwConSize, coordScreen, &cCharsWritten);
GetConsoleScreenBufferInfo(hConsole, &csbi);
FillConsoleOutputAttribute(hConsole, csbi.wAttributes, dwConSize, coordScreen, &cCharsWritten);
SetConsoleCursorPosition(hConsole, coordScreen);
}
and how do i change it from saying: "Quote" to "Code" or something to that effect? i saw someone do that...
why didnt anyone else post their best programs...thats what this was for lol
cuz my programs suck!
all ghetto code~
I've had this for a while, but it's still buggy. I remember that I thought it was neat at the time but I can't for the life of me remember what gave me the idea. Now that I think of it, I may rewrite it and solve the problems as well as update the processing for C++ declarations as well. :D
Sorry, I don't have any of my best C++ programs that I can post without embarassing myself on this computer. Old stuff from programming classes ;)
-PreludeCode:#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
static int cDecl ( void );
static void readTok ( void );
static void firstIdent ( void );
static void decl ( void );
static void pointers ( void );
static void arrays ( void );
static void args ( void );
struct Token { char tok; char buffer[200]; };
struct Token stack[200];
struct Token curr;
int top = -1;
int main( void )
{
printf ( "--Universal Declaration Translator--"
"\n written by Julienne Walker\n"
"\nInstructions: Enter a C style\n"
"declaration at the command line,\n"
"excluding argument names for \n"
"functions and ending with a semicolon.\n"
"\nTo exit the program, type x and hit\n"
"enter.\n"
"\nExamples:\n"
"const char* (*a)(int, char);\n"
"int func(double *, double);\n"
"char *a[50];\n"
"int i;\n\n"
"$: " );
while ( 1 ) {
firstIdent();
decl();
printf ( "\n" );
printf ( "$: " );
}
return EXIT_SUCCESS;
}
int cDecl ( void )
{
char *word = curr.buffer;
if ( !strcmp ( word, "const" ) ) {
strcpy ( word, "constant" );
return 1;
}
else if ( !strcmp ( word, "signed" ) ) return 2;
else if ( !strcmp ( word, "unsigned" ) ) return 2;
else if ( !strcmp ( word, "char" ) ) return 2;
else if ( !strcmp ( word, "short" ) ) return 2;
else if ( !strcmp ( word, "int" ) ) return 2;
else if ( !strcmp ( word, "long" ) ) return 2;
else if ( !strcmp ( word, "float" ) ) return 2;
else if ( !strcmp ( word, "double" ) ) return 2;
else if ( !strcmp ( word, "void" ) ) return 2;
else if ( !strcmp ( word, "struct" ) ) return 2;
else if ( !strcmp ( word, "enum" ) ) return 2;
else return 3;
}
void readTok ( void )
{
char *temp = curr.buffer;
while ( ( *temp = getchar() ) == ' ' ) ;
if ( *temp == 'x' ) {
printf ( "Good day\n");
exit( 0 );
}
if ( isalnum ( *temp ) ) {
while ( isalnum ( *++temp = getchar() ) ) ;
ungetc ( *temp, stdin );
*temp = '\0';
curr.tok = cDecl();
return;
} else if ( *temp == '*' ) {
strcpy ( curr.buffer, "pointer to" );
curr.tok = '*';
return;
}
curr.buffer[1] = '\0';
curr.tok = *temp;
return;
}
void firstIdent ( void )
{
readTok();
while ( curr.tok != 3 ) {
stack[++top] = curr;
readTok();
}
printf ( "%s is a ", curr.buffer );
readTok();
}
void decl ( void )
{
if ( curr.tok == '[' ) arrays();
else if ( curr.tok == '(' ) args();
pointers();
while ( top >= 0 ) {
if ( stack[top].tok == '(' ) {
stack[top--]; readTok(); decl();
} else printf ( "%s ", stack[top--].buffer );
}
}
void pointers ( void )
{ while ( stack[top].tok == '*' ) printf ( "%s ", stack[top--].buffer ); }
void arrays ( void )
{
while ( curr.tok == '[' ) {
printf ( "array " );
readTok();
if ( isdigit ( curr.buffer[0] ) ) {
printf ( "0 - %d ", atoi ( curr.buffer ) - 1 );
readTok();
}
readTok();
printf ( "of " );
}
}
void args ( void )
{
printf ( "function that takes a " );
while ( curr.tok != ')' ) {
readTok();
printf ( "%s ", curr.buffer );
readTok();
if ( curr.tok == '*' ) printf ( "pointer " );
if ( curr.tok != ')' ) {
readTok();
if ( curr.tok == ',' ) printf ( "and " );
}
}
readTok();
printf ( "as arguments and returns " );
}
What does that do? could you compile it and attach a zip file with the exe in it LOL, i wanna see what that does, i cant understand half the code...man i cant wait to learn all that
lol my first thread has 420 views already :D
this is my first semester final project too......
i also has the annoying enter a letter and the program will die glitch too, sorry maybe someday ill fix it :)
>What does that do?
It's a declaration translator. If you enter a C style declaration on the command line then the program will give you the english equivalent. Here's some sample output, but the full code is there and you can compile and run it to try it out.
There is a small error that I fixed from the code I posted though, simply change the args function to thisCode:--Universal Declaration Translator--
written by Julienne Walker
Instructions: Enter a C style
declaration at the command line,
excluding argument names for
functions and ending with a semicolon.
To exit the program, type x and hit
enter.
Examples:
const char* (*a)(int, char);
int func(double *, double);
char *a[50];
int i;
$: double *arg(float, int, double);
arg is a function that takes a float and int and double as arguments and returns pointer to double
$: const char *(*arg)(char, char, double);
arg is a pointer to function that takes a char and char and double as arguments and returns pointer to char constant
$: char string[50];
string is a array 0 - 49 of char
$: int i;
i is a int
$: x
Good day
Press any key to continue
-PreludeCode:void args ( void )
{
printf ( "function that takes a " );
while ( curr.tok != ')' ) {
readTok();
printf ( "%s ", curr.buffer );
readTok();
if ( curr.tok == '*' ) printf ( "pointer " );
if ( curr.tok != ')' ) {
if ( curr.tok == ',' ) printf ( "and " );
}
}
readTok();
printf ( "as arguments and returns " );
}
interesting...very interesting :D
hehe
prelude can you attach the .exe file to your next reply, i wanna play with your program...(did that sounds dirty? :D)
pop quiz to anyone:
How many years will it take for me to become smart at C++!!!! JEEZ!!!!
I don't think I'll ever become smart at c++, maybe someday.....Quote:
Originally posted by Paro
How many years will it take for me to become smart at C++!!!! JEEZ!!!!
To Prelude:
Paro needs the .exe because he doesn't have c++ at home.
thank you :D
maybe at the end of next year ill know something, because im taking C++ next year too :cool:
If that program you posted was your own then your off to a really good start. Just keep it up...
thanks, i will :D
>Paro needs the .exe because he doesn't have c++ at home
Ah, sorry about that. I normally don't send .exe files because most people tend to be suspicious of them when source code is safer.
>How many years will it take for me to become smart at C++
It depends on what you want to do with it, the more complicated your goals are the longer it will take. Just keep working at it and you'll be good before you know it :)
-Prelude
Prelude:
that program is pretty cool, even when i said: const int WIDTH = 3; it said that WIDTH was a constant, and thats pretty cool...good job :D
to prelude:
about how long until i start making win32 dll files that are used to make hacks in diablo2? will i ever get that far? lol :)
im still using console
oh and to all that care, i finally have visual studio 6.0 at home now FULL VERSION SO WOOHOOOOOOOOOO!!!
Ok i have posted my best program as a new thread..under "My best c++ console game " have a look and give me suggestions.. comments etc.. I am aged 18.
Vasanth
cool, i will go download it
i am really confused on why no one except for a few have posted their games here...
Because it's a waste of time.
i guess it is
I dont think so.. games involve both logic and graphics..
im working on my version of "the weakest link" and already i have 1 round set up...
im sorta new to C++ so it doesnt have a time limit... and i havent put in error proof functions so usually if you incorrectly type something it will bug out, well heres my cpp file (im new so its REALLY LONG...)
also keep in mind the questions never change, im not sure how to do it... but i will work on it some more later, this is the first round and after question 10 it will pretty much close...
ill include the exe file if your too lazy to compile it too...:D
umm:
D is elephants, not lions!Code:cout<<"C) Lions\n";
cout<<"D) Elephants\n";
cout<<"\nWhat is your guess? ";
...
cout<<"no, the right answer was D) Lions\n";
Woops, i didnt test it much, thanks for noticing it tho :D
oh, btw, its elephants, not lions... it should be D) Elephants...
hey look, i got more views than the sticky post! heh
first year in high shcool and thats your semester project?! wow you guys must progress slow as hell our school does stuff with stacks and binary search trees,advanced algorithms and the like...Quote:
Originally posted by Paro
You all can reply and post your best programs (the file, not the code lol)
heres my semester project (im a first year programmer in highschool, be nice :))
some input would be nice, criticize it if you want to :(
but by all means, praise me :D
Paro
were in highschool, and our semester project could be anything at all it had to requirement...i didnt use everything we did but yea thats as far as weve been...
you in college or something?
Binary search trees? stacks? advanced algorithms? yeah...those are pretty advanced...except that someone could learn them in about 3 min of reading...paro, know what a pointer is? if not, take 3 min to read what, then 9 min to learn this kids 'advanced' algorithms...and your caught up to his 'genius' school.
ok thanks, ill check ahead in my book for those pointers... even tho i already know how to declare one, i just dont know what they are for, but ill find out :D
Somebody has changed his pictuuuure..... :p
isnt my new picture awesome! :eek:
In my opinion there's only one way to answer to that.
int main() {
if(picture == awesome) {
cout << "It sure is!";
} else {
cout << "Nope, it sucks....";
}
}
that program doesnt solve anything! :p
:D
any ideas for a new newbie program i could make? im stumped :(
Try blackjack and poker. Work on a fast shuffle.
blackjack sounds possible...and i know how to make the characters for the types of cards... hmmm, not a bad idea but it will be kinda hard... oh well its worth a try, ill get back to you guys with a progress report
im in the process of building a blackjack game, but i must admit... it is much harder than i thought possible...
a few problems:
1) Aces can be 1 or 11
2) when it comes out as 12 (queen), i made it automatically be worth 10 (which it should be) but i dont know how to make it so it outputs a Q... or maybe i say
but if i did that it would add up horribly... is there any way to make it so 'Q' is worth 10 when i add it up?Quote:
if(card1==12)
card1=='Q';
thanks for help in advance:D
Do you mind if I rewrite your program and post a copy as my own? I'm interested in seeing how well I can do for modifying it and make it "better" in my eyes. First year programming, myself.
hehe, do whatever you want with it. your talking about the ones at the top right? if so, its no problem :D
Was actually talking about the ones that started this thread. hehe... I'm working on the dice thing myself, using Member Functions and structs. Works nicely here at class.