All pastes #1655001 Raw Edit

Anonymous

public text v1 · immutable
#1655001 ·published 2009-11-03 16:35 UTC
rendered paste body
public class Tester {

       /**
        * @param args
        */
       public static void main(String[] args) {
               int seed= 55;
               String message;
               message = "Stewie Griffin";
               int [] deck = Deck.getExampleDeck();

               //print the original deck
               for (int k=0; k<deck.length; k++){
                       System.out.print(deck[k] + " ");
               }
               System.out.println();

               for (int i=0; i<deck.length; i++){
                       //find card 27 (joker a)
                       if (deck[i]== 27 && i==27){
                               //if joker a is the last card of the deck, swap it with the first
                               int placeHolder= deck[0];
                               deck[0] = deck[i];
                               deck[i] = placeHolder;
                               break;
                       }
                       //if joker a isn't the last card of the deck, swap it with the next card
                       if (deck[i]==27){
                       int placeHolder = deck[i+1];
                       deck[i+1]= deck[i];
                       deck[i]= placeHolder;
                       break;
                       }
               }
               for (int z=0; z<deck.length; z++){
                       System.out.print(deck[z]+" ");
               }
               System.out.println();

               for (int j=0; j<deck.length; j++){
                       //find card 28 (joker b)
                       if (deck[j]==28){
                               int placeHolder;
                               //if joker b is the last card in the deck, move it to the second card
                               if (j==27){
                                       placeHolder= deck[0];
                                       deck[0] = deck[j];
                                       deck[j] = placeHolder;
                                       placeHolder = deck[1];
                                       deck[1]= deck[0];
                                       deck[0]= placeHolder;
                                       break;
                               }
                               // if joker b is the next to last card in the deck, move it to the first card
                               if (j==26){
                                       placeHolder= deck[j+1];
                                       deck[j+1]= deck[j];
                                       deck[j]= placeHolder;
                                       placeHolder= deck[0];
                                       deck[0] = deck[j+1];
                                       deck[j+1] = placeHolder;
                                       break;
                               }
                               //if joker b isn't the last or next to last card, move it down 2 cards in the deck.
                               if (!(j== 26) && !(j== 27)){
                                       placeHolder= deck[j+1];
                                       deck[j+1]= deck[j];
                                       deck[j]= placeHolder;
                                       placeHolder = deck[j+2];
                                       deck[j+2]=deck[j+1];
                                       deck[j+1]= placeHolder;
                                       break;
                               }
                       }
               }
               //print array
               for (int y=0; y<deck.length; y++){
                       System.out.print(deck[y]+" ");
               }
               System.out.println();

               int [] deckTwo =  new int [28];
               int numOfJokers=0;
               int indexTwo=0;
               //move all numbers after the second Joker to the beginning of the new array
               for (int index = 0; index<deck.length; index++){
                       if (isJoker(deck[index])==true){
                               numOfJokers++;
                       }
                       if(numOfJokers==2 && indexTwo<28 && !(deck[index]==27 || deck[index]==28)){
                               deckTwo[indexTwo]=deck[index];
                               indexTwo++;
                       }
               }
               //print array
               for (int w=0; w<deckTwo.length; w++){
                       System.out.print(deckTwo[w]+" ");
               }
               System.out.println();

               //reset number of jokers
               numOfJokers=0;
               //put all of the numbers between the jokers in the second array, including the jokers
               for (int index=0;index<deck.length; index++){
                       if (isJoker(deck[index])==true){
                               numOfJokers++;
                       }
                       if((numOfJokers==1 && indexTwo<28) || (deck[index]==27 || deck[index]==28)){
                               deckTwo[indexTwo]=deck[index];
                               indexTwo++;
                       }
               }
               //print array
               for (int v=0; v<deckTwo.length; v++){
                       System.out.print(deckTwo[v]+" ");
               }
               System.out.println();
               //reset number of jokers
               numOfJokers=0;
               //put all of the numbers before the first joker into the second array
               for (int index=0;index<deck.length; index++){
                       if (numOfJokers==0 && indexTwo<28){
                               deckTwo[indexTwo]= deck[index];
                               indexTwo++;
                       }
               }
               //print array
               for (int x=0; x<deckTwo.length; x++){
                       System.out.print(deckTwo[x]+" ");
               }
               System.out.println();
               //make the deck equal to deckTwo
               deck= deckTwo;
               int lastCard= deck[27];
               System.out.println(lastCard);
               //make an array to store the the first n cards equal to the value of the last
               //card in the deck
               int [] deckThree = new int [deck[27]];
               //store the first n values in the new array
               int indexThree =0;
               for (int i=0; i<deck[27]; i++){
                       deckThree[indexThree]= deck[i];
                       System.out.print(deckThree[indexThree] + " ");
                       indexThree++;
               }
               System.out.println("the length of deck three is: "+deckThree.length);
               System.out.println("last card is: " +lastCard);
               System.out.println();
               //move all but the last card up n places in the original array
               for (int i=0; i<(deck.length-deck[27]); i++){
                       deck[i]= deck[i+deck[27]];
                       System.out.print(deck[i] + " ");
               }
               System.out.println();

               //put the missing n cards back and put the last card back


                for (int i=0; i<27;i++){
                        System.out.print(deck[i]+ " ");
                }
                System.out.println();
       }
       public static boolean isJoker (int cardValue){
               if (cardValue==27 || cardValue==28){
                       return true;
               }
               else{
                       return false;
               }
       }

}