This site requires JavaScript, please enable it in your browser!
Greenfoot back
Chapaladeen
Chapaladeen wrote ...

2015/12/30

If statements causing compiler to crash

Chapaladeen Chapaladeen

2015/12/30

#
Been having an issue with the compiler crashing completely at a certain if statement. I'm going to try changing it up but I really need it in this format.
while(countPlayer <= 5){
           while(countCard <= 3){
           Crash happens between here and  >>  if(cardArray[Random][0] != 0){
               }
               else{
                   cardArray[Random][0] = countPlayer+1;
                   cardArray[Random][countPlayer+1] = countPlayer+1;
                   countCard++;
           Here   >> }
           }
           countPlayer++; 
        }
danpost danpost

2015/12/30

#
Where are 'countPlayer', 'countCard' and 'Random' being initialized and what are they being initialized to? What are the dimensions of the 'cardArray' array? What error message are you getting?
Chapaladeen Chapaladeen

2015/12/30

#
It's not an error message, it compiles but when it tries to run that line of code it just freezes and crashes with no error message. I managed to fix it by moving it into a subroutine. I really don't know why that would fix it but it worked.
You need to login to post a reply.