I am trying to make simple poker game and came to point where the 'number' for an Ace could be either a 13 or a 0 (Ace high vs Ace low). As I am using a Bubble sort to determine straights, I wanted to assign the number of the Ace to both 1 and 13. I Know Java doesn't support dynamic variables, but is there a method that returns an int of both values in such a way it is read as either/or?
Asked
Active
Viewed 74 times
2 Answers
0
why you just dont return a vector of two elements? another way it would be to create a tuple in Java, the solution is here: Using Pairs or 2-tuples in Java
-
Oh tuples. I like that concept, was looking for something similar on another project ty. for this one though, I think it will just end up being an if then in a 'hand' class 'sort' method. the other idea that occurred to me was if I could define my own primitive type, like a number class that has ONLY 14 numbers and loops around on itself. tried looking for it, but got nothing. – Barak Greene Oct 17 '12 at 02:30
0
If on each iteration of bubble sort, you do a comparison that has 2 possible values, you'd end up inconsistent sorts depending on how you compare, for example:
what would you expect the sort result to be from these inputs: K(11), A(01,13), Q(12) Where would you expect A to be after the first step, position 1 or position 3?
The simplest thing would probably be to sort it twice, each with the different value for Ace

TheFabledOne
- 238
- 1
- 14
-
i actually created a class called card { private string suit; //clubs, hearts etc private string face; //jack, ten, deuce etc private int count; //this to determine runs private int value; //this to determine value, ace 14 deuce 1 } – Barak Greene Oct 17 '12 at 02:20
-
the count value is only to determine run not value, hence it could be either 0 or 13 as it could end or start a run. the value will determine its place in the hand (high to low, left to right) – Barak Greene Oct 17 '12 at 02:27