AfterKraft / BlackJack

BlackJack Program for our Group Project
0 stars 0 forks source link

Issues with commits #22

Closed kevinnaruse closed 11 years ago

kevinnaruse commented 11 years ago

I ran into difficulties with commits on Github (again!!!!), so I will have to copy and paste the DeckArrayManager code for the newest version. Here it is...

package com.whitejack.api;

import java.util.ArrayList;

public class DeckArrayManager extends Deck { private int numDecks = 1; private int numCards = 52; private static DeckArrayManager instance; private boolean cardIsPlayable = true; private Card[] card; private int[] deck = new int[52]; private String[] suits = {"Spades", "Hearts", "Diamonds", "Clubs"}; private String[] ranks = {"Ace", "2", "3", "4", "5", "6", "7", "8", "9", "10", "Jack", "Queen", "King"}; private int count = 0; private ArrayList stack = new ArrayList(); private ArrayList heap = new ArrayList(); private ArrayList recycleBin = new ArrayList();

/**
 *  This method is accessed from 
 *  outside the class by 
 *  
 *  deck = DeckArrayManager.getDeckArrayManager();
 * @return
 */
public DeckArrayManager()

}
public DeckArrayManager(int num)
{
    this.numCards = num;
}
public int getCount()
{
    return count;
}
public void setCount(int c)
{
    count = c;
}
public boolean needShuffle()
{
    if (count == 50)
        return true;
    else
        return false;
}
public static DeckArrayManager getDeckArrayManager()
{
    if (instance == null)
    {
        instance = new DeckArrayManager();
        System.out.println("[DeckArrayManager] inside getter() method");
    }
    return instance;
}
public void serveCard()
{
    if (needShuffle() == false)
        count++;
    else
        shuffle();

}

// Recycle all cards into stack
public void initDeck()
{
    for (int i = 0; i < deck.length; i++)
        deck[i] = i;
}
// Shuffle the cards
public void shuffle()
{
    for (int i = 0; i < deck.length; i++) 
    {
      // Generate an index randomly
      int index = (int)(Math.random() * deck.length);
      int temp = deck[i];
      deck[i] = deck[index]; 
      deck[index] = temp;
    }
    System.out.println("[DeckArrayManager] shuffle() method");
}
public void push(ArrayList<Card> list, int card)
{
    list.add(this.card[card]);
}
public void pull(ArrayList<Card> list, int card)
{
    list.remove(card);
}
public void serveHand(int num)
{   // Deal out one hand to one player
    for (int i = count; i < num + count; i++) 
    {
        String suit = suits[deck[i] / 13];
        String rank = ranks[deck[i] % 13];
        System.out.println("Card number " + deck[i] + ": " 
        + rank + " of " + suit);
        count++;
        heap.push(Card[]);
        stack.pull(Card[i]);

    }
    System.out.println("[DeckArrayManager] serveHand() method");
}   

public void displayHand(int num)
{   //Display the first hand of cards with the specified size of cards
    for (int i = 0; i < num; i++) 
    {
        String suit = suits[deck[i] / 13];
        String rank = ranks[deck[i] % 13];
        System.out.println("Card number " + deck[i] + ": " 
        + rank + " of " + suit);    
    }
}
public void getCard() 
{

}
public void setCard() 
{

}
public void getStateMachine()
{

}
public void setStateMachine()
{

}

}

gabizou commented 11 years ago

You know you could edit the code directly through navigating in the website?

https://github.com/AfterKraft/BlackJack/blob/dev/WhiteJack/src/com/whitejack/api/DeckArrayManager.java

Click Edit and then edit away! Make sure though that you're inferring Generic type arguments for the ArrayLists (it's a requirement by ArrayList itself)

gabizou commented 11 years ago

Also, what is Eclipse telling you that you can't commit?

kevinnaruse commented 11 years ago

yup, never mind the earlier mention of problem with commit upstream. it was just a temporary internet glitch, I tried again and it uploaded to github fine. right now i am reading up on the generics website you mentioned, I'll let yo know if I can find any ideas.

kevinnaruse commented 11 years ago

I am about to pull now. I am working on a detailed class definition of Card and getting specifics on DeckArrayManager class worked out. please feel free to throw any pointers, tips, or anything I may have overlooked.

gabizou commented 11 years ago

Ok. I guess that works then.