Object Construction ends Program in GridWorld
I am attempting to create a rather generic Tetris clone in Java using GridWorld. In case you are unfamiliar with the software, it's the AP Computer Science class's case study. I found a tutorial to create a Tetris game in Java, and have been following it fairly smoothly with no errors.
If you'll read the page or so of text that describes the process of creating the game, you will find the part which mentions to "Choose one of the 7 TetrisBlocks to create: TetrisBlockO, TetrisBlockI, TetrisBlockT, TetrisBlockL, TetrisBlock_L, TetrisBlockZ, TetrisBlock_Z". I am at this part of the process, and have pretty much verified that all of my methods work just fine, however, when I use the code that was included in the .pdf file, the code that was behind comment marks, I get errors. I am referring specifically to this code:
Using a similar format, I have gone and created classes for both the TetrisBlockO and TetrisBlockI portions of this, doing almost the exact same things for the TetrisBlockO and I methods as I had done for the original TetrisBlock method. However, when the comment lines are removed to call the constructors for TetrisBlockO and TetrisBlockI, the program ends with a game over screen. I have put print statements into both the if statements and the constructors themselves, and have determined that as soon as the program reaches a line of code for the construction of the I or O blocks, the program just ends.
//if(randNum == 1)
// randomBlock = new TetrisBlockO();
//if(randNum == 2)
// randomBlock = new TetrisBlockI();
//if(randNum == 3)
// randomBlock = new TetrisBlockT();
//if(randNum == 4)
// randomBlock = new TetrisBlockL();
//if(randNum == 5)
// randomBlock = new TetrisBlock_L();
//if(randNum == 6)
// randomBlock = new TetrisBlockZ();
//if(randNum == 7)
// randomBlock = new TetrisBlock_Z();
It doesn't even get to the constructor, and it doesn't start running that class. The program literally just ends. Why is that?
Can someone explain to me what it is doing and if there is any way to solve the problem? Please and thank you.
If anyone requests to see the rest of my code thus far, I'll post it.