Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Ninety Nine
- *
- * @author Dylan Keskinyan
- * @version 12/14/17
- */
- import java.util.Arrays;
- public class NinetyNine
- {
- public int totalValue;
- private final String MAP = "123456789TJQKA";
- private String what;
- String[] numbers = what.split(", ");
- private String[] playersCards = {numbers[1],numbers[2],numbers[3]};
- public int whomstWon()
- {
- String winner;
- String[] numbers = what.split(", ");
- totalValue = Integer.parseInt(numbers[0]);
- Arrays.sort(playersCards);
- for(int i=1;i<numbers.length;i++)
- {
- int added = MAP.indexOf(numbers[i])+1;
- while(totalValue<=99)
- {
- if(i==1)
- {
- if(valueFinder()!=9 && valueFinder()!=10 && valueFinder()!=14)
- {
- totalValue += valueFinder();
- }
- else if(valueFinder()==10)
- {
- totalValue -= 10;
- }
- else if(valueFinder()==14 && totalValue+14<100)
- {
- totalValue += 14;
- }
- else if(valueFinder()!=9)
- {
- totalValue += 1;
- }
- }
- else if(i==2)
- {
- if((MAP.indexOf(playersCards[2])+1)!=9 && MAP.indexOf(playersCards[2]+1)!=10 && MAP.indexOf(playersCards[2]+1)!=14)
- {
- totalValue += MAP.indexOf(playersCards[2])+1;
- }
- else if((MAP.indexOf(playersCards[2])+1)==10)
- {
- totalValue -= 10;
- }
- else if((MAP.indexOf(playersCards[2])+1)==14 && (MAP.indexOf(playersCards[2])+1)+14<100)
- {
- totalValue += 14;
- }
- else if((MAP.indexOf(playersCards[2])+1)!=9)
- {
- totalValue += 1;
- }
- }
- else if(i==3)
- {
- if((MAP.indexOf(playersCards[1])+1)!=9 && MAP.indexOf(playersCards[1]+1)!=10 && MAP.indexOf(playersCards[1]+1)!=14)
- {
- totalValue += MAP.indexOf(playersCards[1])+1;
- }
- else if((MAP.indexOf(playersCards[1])+1)==10)
- {
- totalValue -= 10;
- }
- else if((MAP.indexOf(playersCards[1])+1)==14 && (MAP.indexOf(playersCards[1])+1)+14<100)
- {
- totalValue += 14;
- }
- else if((MAP.indexOf(playersCards[1])+1)!=9)
- {
- totalValue += 1;
- }
- }
- else
- {
- if(added!=9 && added!=10 && added!=14)
- {
- totalValue += added;
- }
- else if(added==10)
- {
- totalValue -=10;
- }
- else if(added==14 && totalValue+14<100)
- {
- totalValue += 14;
- }
- else if(added!=9)
- {
- totalValue +=1;
- }
- }
- }
- if() //see who wins
- {
- }
- }
- }
- public int valueFinder()
- {
- String[] numbers = what.split(", ");
- return Math.max(MAP.indexOf(numbers[0]), Math.max(MAP.indexOf(numbers[1]), MAP.indexOf(numbers[2])))+1;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement