A quick introduction,
I am very new to java programming, i have only taken an intro java course at my university. Since then i have been trying for the most part to teach myself. My way of doing this was to create a bare-bones black jack program and slowly build upon it as i learn. I had a working code, but it was sloppy and only used the main method. Since i've learned a little more about method calls, i've been trying to break my existing code down into organised classes and methods.
With that said,
the current issue i am running into now is implementing a variable that exists in another class. now i know i am supposed to create an object of a class before i can use it, but the class i am trying to call is already made into an object by "main" and creating a second object in a different class causes undesired effects.
Keeping in mind that i am very new and have limited knowledge of programming, i would like to find a work around for this issue. I'm taking baby steps right now.
Here's the code that is causing my issue (i can post more of the code if needed, also i will attach the source package).
ISSUE IS IN "PRINTERS" CLASSpublic class DealCard { Deck deck = new Deck(); Random generator = new Random(); boolean recieved; boolean pHasAce=false; boolean dHasAce=false; int dAce=0; int pAce=0; int card; int a=0; int b=0; boolean[] dealt = new boolean[52]; public void dealDealer() { { recieved = false; while (!recieved) { card = generator.nextInt(51); if (dealt[card]==false) { dealt[card]=true; deck.dealerHandCard[a] = deck.deck[card]; deck.dealerHandValue[a] = deck.value[card]; a++; recieved=true; if (deck.value[card]==11) { dHasAce=true; dAce++; } } } } }
public class Printers { public void printPlayerHandString() { System.out.print("Player has "); for (int i=0; i<DealCard.b; i++) { System.out.print(playerHandCard[i]+" "); } } }
PACKAGE
black jack package.zip