Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!

# Help how to start a Play your cards right game?

Tom-Colin Kelly
Greenhorn
Posts: 27
Hello

I wouldn't say i am very new to java, i am just not too good at it and i am doing various programs to get better. However my biggest weakness is starting a project, i would never know where to start. Here i am wanting to create a game called play your cards right.

Here is the document i have about the game:

For your assessment point, you will need to create a program to simulate the TV game show play your cards right.
- The basic idea is that the user is presented with a starting number between 1-13;
- The user then has to state whether the next number will be higher or lower;
- If the next number is the same as the previous they loose;
- If they guess correctly they get another go and they receive 100points;
- If they get 5 correct in a row they a bonus of 1000points;
- They loose all money if they get a card wrong and the game ends;

Screen output example…
- Starting number is 5
- Please enter higher or lower…
- Higher
- Next card is 7: You win 100, your total is 100
- Please enter higher or lower:
- Lower
- Next card is 4: You win 100, your total is 200
- Higher
- Next card is 1: You loose, your total is 0

Hints:
- You will need to use a random number to generate the next card;
- You will need a while loop that will exit when the user looses;
- you will need a selection statement to check if the user has guessed correctly;
- You will need to store what the starting number, previous number and current number is;

Extension
- Give the user a starting credit of 50
- The game costs 20 per play
- Keep track of the total
- Display game over if they run out of credit.

Could you help me how to start the project, and how to go about starting future projects, thanks
Sorry for the long post!

Tom

Rajkamal Pillai
Ranch Hand
Posts: 445
1

As Java is all OO and in this world we talk about different Objects and how they interact with each other, you should start of by modelling your scenario in an Object oriented fashion.

I feel that should make a good start.

Keep posting.....

Cheers,
Raj.

fred rosenberger
lowercase baba
Bartender
Posts: 12127
30
I always start every project by turning my computer off. I get pencil and paper, and I start writing things down. What do I need to do? What objects make sense? What do those objects need to be able to do? Do I need a group of objects, and if so, how do i need to access them (sequentially, randomly, etc) and will I need to delete them?

Once I've spent several hours thinking, drawing, and writing, then I write something like this, and no more:

Once that works, I start adding in bits and pieces, but never more than 2-3 lines of new code at a time before I recompile and retest.

Tom-Colin Kelly
Greenhorn
Posts: 27
fred rosenberger wrote:I always start every project by turning my computer off. I get pencil and paper, and I start writing things down. What do I need to do? What objects make sense? What do those objects need to be able to do? Do I need a group of objects, and if so, how do i need to access them (sequentially, randomly, etc) and will I need to delete them?

Once I've spent several hours thinking, drawing, and writing, then I write something like this, and no more:

Once that works, I start adding in bits and pieces, but never more than 2-3 lines of new code at a time before I recompile and retest.

Ah i understand thanks a lot
so i figure out what classes i want and what i want them to do etc?

Wesleigh Pieters
Ranch Hand
Posts: 81
Yes you need to figure out what objects you need to create, what states they can hold and what behaviors they have.