Deal or No Deal

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

[374 byte] By [Supra06a] at [2007-10-3 10:51:12]
# 1
Try to get something started, then come back here if you need help.
CaptainMorgan08a at 2007-7-15 6:16:24 > top of Java-index,Other Topics,Java Game Development...
# 2

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

yahwehagapea at 2007-7-15 6:16:24 > top of Java-index,Other Topics,Java Game Development...
# 3
> 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.
CaptainMorgan08a at 2007-7-15 6:16:24 > top of Java-index,Other Topics,Java Game Development...
# 4
> 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.
YAT_Archivista at 2007-7-15 6:16:24 > top of Java-index,Other Topics,Java Game Development...
# 5
> 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.
CaptainMorgan08a at 2007-7-15 6:16:24 > top of Java-index,Other Topics,Java Game Development...
# 6
i am also taking a compter programming class and was wondering what the {true, true, true...} was for when you said to make an arrayandHow do you "Ask user to choose a case, store that value in a varible, change it's corresponding boolean caseInPlay value to false."
sam1990109a at 2007-7-15 6:16:24 > top of Java-index,Other Topics,Java Game Development...
# 7

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!

ArikArikArika at 2007-7-15 6:16:24 > top of Java-index,Other Topics,Java Game Development...
# 8

@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

prometheuzza at 2007-7-15 6:16:24 > top of Java-index,Other Topics,Java Game Development...
# 9
thanks for the conventions link.I took a look at it, I'll work on that.
ArikArikArika at 2007-7-15 6:16:24 > top of Java-index,Other Topics,Java Game Development...