Question: I've been trying different methods to fix my code but cant find the error. I keep getting 0 % or 1 0 0 % based

I've been trying different methods to fix my code but cant find the error. I keep getting 0% or 100% based on bricked or not bricked.
What were trying to find is the conditional probability of, given that youve already drawn a valid hand that has a pokemon in it, what are the odds that all of your rare candies got drawn in the 6 prizes (which = bricked)
public void RareCandyDeck(){
resetDeck();
resetHand();
int totalDeckSize =60;
int rareCandyCount =4;
int pokemonCount = totalDeckSize - rareCandyCount;
for (int i =0; i < pokemonCount; i++){
deck.add(new Pokemon("pikachu"));
}
for(int i=0; i < rareCandyCount; i++)
{
deck.add(new Trainer("rareCandy"));
}
Collections.shuffle(deck);
}
public void rareCandySimulator(){
for (int i =0; i <61; i++){
int notBricked =0;
int bricked =0;
int trials =10000;
for (int j =0; j < trials; j++){
boolean validHand = false;
while (!validHand){
resetHand();
resetDeck();
RareCandyDeck();
drawHand();
if (isHandValid()){
validHand = true;
if (deck.size()>=7){
for (int k =0; k <6; k++){
prizePile.add(deck.remove(0));
}
} else {
resetHand();
drawHand();
}
int candiesinPrizePile =0;
for (Card card : prizePile){
if (card.getName().equals("rareCandy")){
candiesinPrizePile++;
}
}
if (candiesinPrizePile ==4){
bricked++;
} else {
notBricked++;
}
}
}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!