Results 1 to 8 of 8
- 08-20-2010, 08:20 AM #1
Member
- Join Date
- Aug 2010
- Posts
- 2
- Rep Power
- 0
- 08-20-2010, 08:30 AM #2
Member
- Join Date
- Aug 2010
- Posts
- 2
- Rep Power
- 0
this program main method:
import java.util.ArrayList;
import java.util.List;
public class GameMain extends Item {
public static void main(String[] args) {
List <Item> itemList = new ArrayList<Item>();
itemList.add(new Paper("Paper"));
itemList.add(new Scissors("Scissors"));
itemList.add(new Stone("Stone"));
for(Item item1: itemList){
for(Item item2:itemList){
System.out.print(item1 + "<--->" + item2 + " ");
item1.match(item2);
}
}
}
}
- 08-20-2010, 01:23 PM #3
How are you representing the players? And their choices?
- 08-20-2010, 01:41 PM #4
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,606
- Blog Entries
- 7
- Rep Power
- 17
If you have to do it completely without if statements you have to assign a rank to rock, scissors, paper, e.g. 0, 1, 2. You also have to define a 'decistion matrix' that tells the user who has won, e.g.
The row index is the computer's guess, the column index is the human's guess.Java Code:String[][] win= { { "tie", "computer wins", "human wins" }, { "human wins", "tie", "computer wins" }, { "computer wins", "human wins", "tie } };
kind regards,
Jos
- 08-20-2010, 02:03 PM #5
Senior Member
- Join Date
- Aug 2010
- Posts
- 127
- Rep Power
- 0
I'd say use a switch statement.
- 08-20-2010, 02:06 PM #6
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,606
- Blog Entries
- 7
- Rep Power
- 17
- 08-20-2010, 02:33 PM #7
Senior Member
- Join Date
- Aug 2010
- Posts
- 127
- Rep Power
- 0
- 08-20-2010, 02:44 PM #8
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,606
- Blog Entries
- 7
- Rep Power
- 17
Similar Threads
-
Stone, Paper, Scissors game help
By Harris68 in forum NetworkingReplies: 1Last Post: 12-19-2009, 04:33 PM -
Rock, Paper, Scissor Game Help
By CYANiDE in forum New To JavaReplies: 6Last Post: 10-28-2009, 04:20 PM -
Rock Paper Scissors
By 54byler in forum Advanced JavaReplies: 2Last Post: 04-23-2009, 06:23 AM -
Need Help with Rock paper and Scissors Java Game
By kingsun in forum New To JavaReplies: 3Last Post: 11-17-2008, 03:35 AM -
Need help with Rock Paper Scissors Game
By GettinGwap in forum New To JavaReplies: 12Last Post: 10-19-2008, 06:15 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks