participate


Java Game Development - Deal or No Deal
<<   Back to Forum  |   Give us Feedback
This topic has 9 replies on 1 page.
Supra06
Posts:1
Registered: 11/26/06
Deal or No Deal   
Nov 26, 2006 2:34 PM

 
Hello,

I am a student and I am taking programming, I was wondering how I would go about making a simple java version of the game show "Deal or No Deal". I am doing this for a project and I am using Netbeans, it doesnt have to be complex and I was just wondering where to start. Any help would be appreciated, thanks!

Message was edited by:
Supra06
 
CaptainMorgan08
Posts:5,603
Registered: 10/05/06
Re: Deal or No Deal   
Nov 26, 2006 2:47 PM (reply 1 of 9)  (In reply to original post )

 
Try to get something started, then come back here if you need help.
 
yahwehagape
Posts:18
Registered: 11/25/06
Re: Deal or No Deal   
Nov 26, 2006 2:56 PM (reply 2 of 9)  (In reply to original post )

 
the difficult part would be divsing an equation to output the price the boss would pay for each case configuration.

how would you start?
well, make the varibles for each case value (a final int[]) with each value assigned.
make another array: boolean[] caseInPlay = {true, true,true,true ....}
Ask user to choose a case, store that value in a varible, change it's corresponding boolean caseInPlay value to false.
then make a loop that runs for 5 (i think) times, then 4, 3, 2, 1, and then always 1. This loop is to have the user guess a case.
After the loop, strike the deal with your equation, give the deal/no deal option.
if nodeal then go back to the loop and loop for the next amount of times (first time through loop, it would ask for case 5 time, second time ask for case 4 times)

something like that.

null
 
CaptainMorgan08
Posts:5,603
Registered: 10/05/06
Re: Deal or No Deal   
Nov 26, 2006 3:18 PM (reply 3 of 9)  (In reply to #2 )

 
the difficult part would be divsing an equation to
output the price the boss would pay for each case
configuration.

I think he just averages all the remaining cases together. It changes when it gets close to the end though.
 
YAT_Archivist
Posts:1,713
Registered: 8/13/05
Re: Deal or No Deal   
Dec 10, 2006 2:18 PM (reply 4 of 9)  (In reply to #3 )

 
I think he just averages all the remaining cases together.

On the basis of the one episode I've seen (which, if it matters, was the British version), it seemed a lot more psychological than that.
 
CaptainMorgan08
Posts:5,603
Registered: 10/05/06
Re: Deal or No Deal   
Dec 10, 2006 2:44 PM (reply 5 of 9)  (In reply to #4 )

 
On the basis of the one episode I've seen (which, if
it matters, was the British version), it seemed a lot
more psychological than that.

In the American version, it seems like he averages all the cases together for the first 1/2 - 2/3 of the cases.
 
sam1990109
Posts:1
Registered: 1/14/07
Re: Deal or No Deal   
Jan 14, 2007 2:38 PM (reply 6 of 9)  (In reply to #2 )

 
i am also taking a compter programming class and was wondering what the {true, true, true...} was for when you said to make an array

and

How do you "Ask user to choose a case, store that value in a varible, change it's corresponding boolean caseInPlay value to false."
 
ArikArikArik
Posts:102
Registered: 8/12/06
Re: Deal or No Deal   
Jan 15, 2007 8:37 AM (reply 7 of 9)  (In reply to #6 )

 
Personally... I dont know how to win the game. But I have played it before and I can help you with the tray part.

Have an array of boolean (true/false) representing which trays are in play and which trays are not. True is in play and false is out of play.

int number_of_trays = 30;
boolean trays[] = new boolean[number_of_trays];


Assign the price values to each tray randomly based on a List (possible) that had all the values initially.

java.util.List food_items = new java.util.ArrayList();
// Populate list of food items...
food_items.add( "Chicken - 600$" );
food_items.add( "Potato - 55$" );
food_items.add( "Cow Liver - 10,000$" );
// etc....


If youd rather make this object oriented you could create an foo_item object with a name variable and price variable.

public class food_item
{
String name;
int price;
public food_item( String n, int p )
{
name = n;
price = p;
}
// bla bla make some get/set methods
// such as:
public void setName( String n )
{
name = n;
}
 
public String getName()
{
return name;
}
//etc...
}
 
///////////////////////////////////////////
// Somewhere in the game initilization
///////////////////////////////////////////
 
java.util.List food_items = new java.util.ArrayList();
// populate list based on objects
food_items.add( new food_item( "Chicken",600) );
food_items.add( new food_item( "Potato",55) );
food_items.add( new food_item( "Cow Liver",10000) );
// later you can extract these values


Ok... theres more to be done. Right now you have:
1) java.util.List food_items = new java.util.ArrayList(); //populated list
2) int number_of_trays = food_items.size(); //numb of trays = numb of items
3) boolean trays[] = new boolean[number_of_trays];

good, good... Now you want to extract the food_items out of the list and assign them random index values from 0 to number_of_trays. You do this to make the game platters random each time.

java.util.Random rand = new java.util.Random(); //random numb generator
food_item item_index[] = new food_item[number_of_trays]; //all are null on initilization
for ( int i = 0; i < number_of_trays; ) //loop until all indeces are used (non-null)
{
int index = rand.nextInt(number_of_trays); //choose random number from 0 to number_of_trays, assign it to index
if ( item_index[index] == null ) //if index is empty
{
item_index[index] = (food_item)food_items.get(0); //get FIRST food item from list and store into item_index array
food_items.remove(0); //remove FIRST food item from list
// all other food items are left
i++; //increment counter by one because a food_item was assigned a platter
}
}


BAM! I gave you alot of goodies here.
you can use that to initilize your game meaning:
Get X number of trays with X number of food items and they will be randomly placed in different "platters" of the item_index array.

Second question:
To choose cases. If this is a console game do a google search on "Scanner Java" and go to the javadocs link to use the Scanner input command.
If this is graphical. Then you make a JFrame, then extend a JPanel for the "GameBoard." For each food_item in the array you should draw a platter with "Graphics.drawImage(Image,x,y,null);". To select any one of the platters, you MUST KNOW WHERE YOU DREW THEM!!! If you can track down the places that you placed the platters then use the distance equation (WHICH YOU BETTER KNOW) to find how far the mouse is from a platter. If distance <= then X where X is the radius, then you select that platter on click. Better?
Good.

Your welcome. I gotta study for midterms now... so bye!
 
prometheuzz
Posts:15,167
Registered: 7/28/05
Re: Deal or No Deal   
Jan 16, 2007 6:17 AM (reply 8 of 9)  (In reply to #7 )

 
@ArikArikArik: you have a class called food_item and a variable called food_items, which is very confusing, IMO.
Following the Java code convention this should be FoodItem (class name) and foodItems (variable name).
Details: http://java.sun.com/docs/codeconv/html/CodeConvTOC.doc.html
 
ArikArikArik
Posts:102
Registered: 8/12/06
Re: Deal or No Deal   
Jan 18, 2007 11:59 AM (reply 9 of 9)  (In reply to #8 )

 
thanks for the conventions link.
I took a look at it, I'll work on that.
 
This topic has 9 replies on 1 page.
Back to Forum
 
Read the Developer Forums Code of Conduct

Click to email this message Email this Topic

Edit this Topic
  
 
 
Forums Statistics
    Users Online : 28
  • Guests : 133

About Sun forums
  • Oracle Forums is a large collection of user generated discussions. It is here to help you ask questions, find answers, and participate in discussions.

    Check out our guide on Getting started with Oracle Forums for a full walkthrough of how to best leverage the benefits of this community.

Powered by Jive Forums