Apparently asking for help while offering $$ is = to getting someone to do all your work for you.
Welcome to the Java Programming Forums
The professional, friendly Java community. 21,500 members and growing!
The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.
>> REGISTER NOW TO START POSTING
Members have full access to the forums. Advertisements are removed for registered users.
Apparently asking for help while offering $$ is = to getting someone to do all your work for you.
Last edited by DaffyPWNS; September 15th, 2011 at 11:41 AM.
So you're trying to pay somebody to do your homework for you? That is not what these forums are for. Also, it's almost definitely against your school's academic dishonesty policy, which could get you expelled or worse.
Why not ask a question? Why not break your problem up into a smaller problem? Write a much smaller program (an SSCCE) that does only one thing: asks for user input a certain number of times, or until a certain condition is met. Then it will be much easier to see what's going on, and you won't have to pay anybody anything to help you cheat.
Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!
/////////////
I don't want someone to do the entire program for me or else I wouldn't of posted what I had. I just need guidance on what to do.
That's way too much code for anybody to wade through. Plus it's not indented, which makes it impossible to read. We've got hundreds of posts here, and we're all doing this for free, so we just don't have time to spend on that kind of thing.
I'd recommend you boil your program down to that SSCCE- isolate the loop in question, and write a tiny program that only deals with that one loop.
Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!
Alright thanks Kevin will do .
Here's my attempt at an SSCE
Check what I need above .
Basically after getting the users cards I need to println ("Place a bet") but it not to show up the second time let's say I call again. Only once. Also I need help with the math to figure out how I can make it so when the user looses he looses his bet , wins = 3 times his bet and tie = get bet back.
Thanks for looking
while( true ) { con.clear(); con.println("Username:" + strUsername); con.println("Money: $" + money); con.println("Games Won: " + numWon); con.println("Games Lost: " + numLost); con.println(); con.println("My Cards:"); int plrTotal1 = 0; int plrTotal2 = 0; boolean plrAce = false; for( int i = 0; i < given; i++ ) { con.println("Card " + (i + 1) + ": " + nameCards[plrCards[i]] + " of " + nameSuits[plrSuits[i]]); if( plrCards[i] == A ) { plrAce = true; plrTotal1 += 1; plrTotal2 += 11; } else { plrTotal1 += valueCards[plrCards[i]]; plrTotal2 += valueCards[plrCards[i]]; } } int compTotal1 = valueCards[compCards[0]]; int compTotal2 = valueCards[compCards[0]]; boolean compAce = false; if( compCards[0] == A ) { compAce = true; compTotal2 += 10; } con.println(); con.println("Dealer Cards:"); if( finished ) { int numCompCards = 2; compTotal1 = 0; compTotal2 = 0; compAce = false; int temp1 = 0; int temp2 = 0; boolean tempAce = false; for( int i = 0; i < maxGiven; i++ ) { temp1 += valueCards[compCards[i]]; temp2 += valueCards[compCards[i]]; if( compCards[i] == A ) { tempAce = true; temp2 += 10; } if( 16 <= temp1 && temp1 <= 21 || tempAce && 16 <= temp2 && temp2 <= 21 || temp1 > 21 ) { numCompCards = i + 1; break; } if( temp1 > 21 ) { temp1 -= valueCards[compCards[i]]; numCompCards = i; break; } } compTotal1 = 0; compTotal2 = 0; compAce = false; for( int i = 0; i < numCompCards; i++ ) { compTotal1 += valueCards[compCards[i]]; compTotal2 += valueCards[compCards[i]]; if( compCards[i] == A ) { compAce = true; compTotal2 += 10; } con.println("Card " + (i + 1) + ": " + nameCards[compCards[i]] + " of " + nameSuits[compSuits[i]]); } } else { con.println("Card 1: " + nameCards[compCards[0]] + " of " + nameSuits[compSuits[0]]); con.println("Card 2: - 2nd Dealer Card Hidden-"); } con.println(); if( plrAce ) { if( plrTotal1 <= 21 ) { con.println("My Value 1: " + plrTotal1); } else { con.println("My Value 1: " + plrTotal1 + " [BUSTED]"); } if( plrTotal2 <= 21 ) { con.println("My Value 2: " + plrTotal2); } else { con.println("My Value 2: " + plrTotal2 + " [BUSTED]"); } } else { if( plrTotal1 <= 21 ) { con.println("My Value: " + plrTotal1); } else { con.println("My Value: " + plrTotal1 + " [BUSTED]"); } } con.println(); if( compAce ) { con.println("Dealers' 1st Value: " + compTotal1); con.println("Dealer's 2nd Value: " + compTotal2); } else { con.println("Dealer Value: " + compTotal1); } con.println(); if( plrTotal1 > 21 ) { numLost++; money -= bust; con.println("You busted!"); con.println(); con.println("Play again? 1=Yes 0=No"); answer = con.readInt(); if( answer == 1 ) { given = 2; finished = false; generateCards(); con.clear(); continue; } else { break; } } if( !finished ) { con.println(); con.println("Do you want another card? 1=Yes 0=No"); answer = con.readInt(); if( answer == 1 ) { given++; } else { finished = true; } } else { con.println(); // Calculate computer total if( plrAce ) { if( compAce ) { if( 21 >= plrTotal1 && plrTotal1 > compTotal1 && 21 >= plrTotal1 && plrTotal1 > compTotal2 || 21 >= plrTotal2 && plrTotal2 > compTotal1 && 21 >= plrTotal2 && plrTotal2 > compTotal2 || compTotal1 > 21 ) { numWon++; con.println("You won!"); money += win; } else { numLost++; con.println("You lost!"); money -= lose; } } else { if( 21 >= plrTotal1 && plrTotal1 > compTotal1 || 21 >= plrTotal2 && plrTotal2 > compTotal1 || compTotal1 > 21 ) { numWon++; con.println("You won!"); money += win; } else { numLost++; con.println("You lost!"); money -= lose; } } } else { if( compAce ) { if( 21 >= plrTotal1 && (plrTotal1 > compTotal1 || compTotal1 > 21) && (plrTotal1 > compTotal2 || compTotal2 > 21) || compTotal1 > 21 ) { numWon++; con.println("You won!"); money += win; } else { numLost++; con.println("You lost!"); money -= lose; } } else { if( 21 >= plrTotal1 && plrTotal1 > compTotal1 || compTotal1 > 21 ) { numWon++; con.println("You won!"); money += win; } else { numLost++; con.println("You lost!"); money -= lose; } } } con.println(); con.println("Play again? 1=Yes 0=No");
Last edited by DaffyPWNS; June 8th, 2011 at 02:28 PM.
Well, that's not really an SSCCE- it should be runnable just by copying and pasting it into an IDE (short, self-contained, compilable example).
That being said, I still don't really know what your question is. What does your program do now? What do you expect it to do? Again, I recommend abstracting the problem away from blackjack- do you need a loop that runs a certain number of times, or a loop that runs until a certain condition is met?
Pretend you have a really dumb friend who has no idea how to deal blackjack. Write out directions that the friend could follow to successfully be a dealer. When you have those written out, you should have an algorithm that should be pretty easy to translate to code.
I'd also recommend breaking your problems up into different methods- keeping everything in the main method like that is really messy.
Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!