@@ -0,0 +1,1773 @@
+package tetris;%0A%0A/**%0A * Proxy that holds and 'randomizes' the upcoming pieces. Tetris random upcoming pieces%0A * are a random ordering of all seven pieces, not necessarily a random piece each time.%0A * This guarantees a level of consistency and a maximum of 12 tetrominoes in between%0A * I blocks.%0A * %0A * @author dmayans%0A */%0A%0Apublic class UpcomingPieces %7B%0A%09%0A%09private int%5B%5D _pieces; // Current set of seven pieces%0A%09private int%5B%5D _next; // Next set of seven pieces.%0A%09private int _counter;%0A%09%0A%09public UpcomingPieces() %7B%0A%09%09_pieces = new int%5BConstants.TETROMINOES.length%5D;%0A%09%09_next = new int%5BConstants.TETROMINOES.length%5D;%0A%09%09// Sets up initial tetrominoes%0A%09%09for(int i=0; i%3CConstants.TETROMINOES.length; i++) %7B%0A%09%09%09_pieces%5Bi%5D = i;%0A%09%09%09_next%5Bi%5D = i;%0A%09%09%7D%0A%09%09this.shuffle(_pieces);%0A%09%09this.shuffle(_next);%0A%09%09this.push();%0A%09%7D%0A%09%0A%09// Method called to push the list forward and generate a new tetromino at the end%0A%09public int push() %7B%0A%09%09if(_counter == Constants.TETROMINOES.length-1) %7B%0A%09%09%09for(int i=0; i%3CConstants.TETROMINOES.length; i++) %7B%0A%09%09%09%09_pieces%5Bi%5D = _next%5Bi%5D;%0A%09%09%09%7D%0A%09%09%09_counter = 0;%0A%09%09%09this.shuffle(_next);%0A%09%09%7D else %7B%0A%09%09%09_counter++;%0A%09%09%7D%0A%09%09return _pieces%5B_counter%5D;%0A%09%7D%0A%09%0A%09private void shuffle(int%5B%5D x) %7B%0A%09%09// Simple Fisher-Yates shuffle%0A%09%09for(int i=0; i%3Cx.length; i++) %7B%0A%09%09%09int rand = (int) (Math.random()*(x.length-i)) + i;%0A%09%09%09int temp = x%5Bi%5D;%0A%09%09%09x%5Bi%5D = x%5Brand%5D;%0A%09%09%09x%5Brand%5D = temp;%0A%09%09%7D%0A%09%7D%0A%09%0A%09public void shuffle() %7B%0A%09%09this.shuffle(_next);%0A%09%09this.shuffle(_pieces);%0A%09%09_counter = 0;%0A%09%7D%0A%0A%09// Used by the shell to peek and display upcoming pieces%0A%09// (this is why an array is being used instead of a queue)%0A%09public int peek(int index) %7B%0A%09%09if(index+_counter%3CConstants.TETROMINOES.length) %7B%0A%09%09%09return _pieces%5Bindex+_counter%5D;%0A%09%09%7D%0A%09%09return _next%5Bindex+_counter-Constants.TETROMINOES.length%5D;%0A%09%7D%0A%7D%0A

Create UpcomingPieces.java