Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Need help with assignment due tomorrow  RSS feed

 
zac fino
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I need help, this assignment is due tomorrow at 4pm and I'm stumped. I don't know how to make it so instead of just starting the game when I press run, make a dialog box come up with 3 options, they type 1 if they want to play a game, 2 to view the rules of the game, or 3 to exit. I know its silly but I'm just drawing a blank. I also dont know how to incorperate a while loop once the player looses or wins, asking if they want to play again (yes/no). Please any help would be great I really need this good grade.


 
Les Morgan
Rancher
Posts: 768
19
C++ Java MySQL Database Netbeans IDE Oracle Tomcat Server
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Good luck, if that is your code, I do not see how you don't know how to do the rest.
 
Winston Gutkowski
Bartender
Posts: 10573
65
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
zac fino wrote:I need help, this assignment is due tomorrow at 4pm and I'm stumped.

On a Saturday? Whatever, you've probably left it far too late for us to be able to help you much this time.

However, the basic answer to your question is something like:or alternatively you could put the whole thing in a for loop that basically does the same thing; but there's so much code there that it's hard to sort out the wood from the trees.

It looks to me like you've just started coding without much of a plan, expecting to be able to code your way to a solution - well, take it from an old soldier: IT WON'T WORK.

Next time, sit down for several hours before you write a single line of code, and write down on paper exactly what it is you need to do.
How does Blackjack work? What are the rules? What classes are you likely to need? And - most importantly - what order do you need to do things?

If you can come up with a proper plan, you can then write your program piece by piece, testing things as you go along so that you don't suddenly end up with 462 lines of code that don't work, and you have no idea why. Or - as in this case - you find you have to add something, and you don't know where to start.

Good programming is about breaking down problems, NOT writing code; so the better you understand your problem, the better your code will be. Indeed, professionals spend about 20% of their time actually coding - and often less. The rest is spent thinking, analysing, making lists and drawing diagrams to get things clear in their mind. And once you get there, coding should simply be a translation exercise.

Hope it helps ... and next time, don't wait till the last minute to ask for help.

Winston

[Edit] Fixed after Campbell's sharp-eyed post. Doh-h-h!
 
Campbell Ritchie
Marshal
Posts: 55741
163
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
…apart from the fact that continue is a keyword.
 
Winston Gutkowski
Bartender
Posts: 10573
65
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Campbell Ritchie wrote:…apart from the fact that continue is a keyword.

Aagh, what a moron I am! Well spotted that man; have a cow.

Winston
 
Campbell Ritchie
Marshal
Posts: 55741
163
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you for the cow. Lots of people make that sort of mistake. I remember when I was starting spending about 1½ hours struggling with compiler errors about a Dice class which had a throw#() method. When I finally twigged what the problem was, I changed that to throws(). At least then it only took me a few seconds to guess the cause of the compiler error! I was mentioned in the next lecture because I sent Elizabeth an email saying I hoped she wouldn't throw me out or throw something at me for that mistake.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!