Code (Java) pasted on 2019-01-31, 23:23 Raw Source
- import java.util.*;
- public class Solution {
- (new Test()).test();
- }
- static class TetrominoBag {
- private LinkedList<Character> tetrominos = new LinkedList<>();
- public TetrominoBag() {
- }
- public TetrominoBag(long randomSeed) {
- }
- private void refillBag() {
- assert(tetrominos.isEmpty());
- tetrominos.add('I');
- tetrominos.add('T');
- tetrominos.add('S');
- tetrominos.add('Z');
- tetrominos.add('O');
- tetrominos.add('L');
- tetrominos.add('J');
- }
- if (tetrominos.isEmpty()) {
- refillBag();
- }
- return tetrominos.poll();
- }
- }
- static class Test {
- private TetrominoBag bag;
- public void test() {
- bag = new TetrominoBag(1);
- testTetromino('Z');
- testTetromino('I');
- testTetromino('L');
- testTetromino('T');
- testTetromino('S');
- testTetromino('J');
- testTetromino('O');
- testTetromino('L');
- }
- private void testTetromino(char expected) {
- if (actual == expected) {
- } else {
- }
- }
- }
- }