Alex D, Tony C, Josh P, Xinning W, Jake DiB, Santiago S, Peng Pong Chen, Meng Y, 
Andrzej K, Shichao H, Dustin K, Omar W, Creighton H, Morgan N, Ethan Y, Joel P, 
Jeremy B, Sean O'Con, Yingzhen Q, Joey C, Anna McN, Will T, Zhengyu L, Kellen A, 
Andrew D, Dimas McD, Troy S, Josh M, Thomas A, Sam Berron, Chen Cheng, Sean Peters, 
Megan H, Jay K, Angely P, Adam K, Laura H, Nikita H, Scott M, Hao T, Yangjun L, 
Maro R, Caleb G, Austin M, Qin N, Biao Z, David L, Wonyong H, Seth Xiaohui W, 
Clayton T, Quintin L, Rishu S, Yongtao Chu, Brittany H, Noah P, Tian J, Jordan L,
Ryan P, Stephen B, Danny N, Jacob C

What's Stage One? A World interface, a BigBang class and a Tetris class (w/ main) 

import java.awt.*; 
import java.awt.event.*; 
import javax.swing.*; 

class Tetris implements World {
  public void draw(Graphics g) { System.out.println("World being drawn."); } 
  public void update() { System.out.println("World getting older."); }
  public boolean hasEnded() { return false; } 
  public void keyPressed(KeyEvent e) { System.out.println("Ouch."); } 
  public static void main(String[] args) {
    BigBang game = new BigBang(200, new Tetris()); 
    JFrame frame = new JFrame("Tetris"); 
    frame.getContentPane().add( game ); 
    frame.addKeyListener( game ); 
    frame.setVisible(true); 
    frame.setSize(400, 400); 
    game.start(); 
  }
}

This class the basic Tetris game. 

import java.awt.*; 
import java.awt.event.*; 

interface World {
  public void draw(Graphics g);
  public void update(); 
  public boolean hasEnded();
  public void keyPressed(KeyEvent e); 
}

This interface is part of the general game framework. 

import javax.swing.*;
import java.awt.event.*; 
import java.awt.*; 

class BigBang extends JComponent implements KeyListener, ActionListener {
  Timer timer; 
  World world; 
  BigBang(int delay, World world) {
    timer = new Timer(delay, this); 
    this.world = world;
  } 
  public void start() {
    timer.start();  
  }
  BigBang(World world) {
    this(1000, world);  
  }
  public void paintComponent(Graphics g) {
    world.draw(g);  
  }
  public void actionPerformed(ActionEvent e) {
    world.update(); 
    if (world.hasEnded())
      timer.stop(); 
    this.repaint(); 
  }
  public void keyPressed(KeyEvent e) { 
    world.keyPressed(e); 
  } 
  public void keyTyped(KeyEvent e) { } 
  public void keyReleased(KeyEvent e) { } 
}

What's Stage Two? 

int[][] a = new int[3][5]; // matrix of 3 rows and 5 columns 

a[1][2] = 6; // third element second row becomes six

Stage Two should be our attempt to start converting this:

http://silo.cs.indiana.edu:8346/c212/spr2015/tetris.rkt

Let's try to convert it. 

The board is 20 rows and 10 columns of 20x20 blocks. 

class Block {
  int x, y;
  Color color; 
  Block(int x, int y, Color c) {
    this.x = x; 
    this.y = y; 
    this.color = c;
  } 
  boolean equals(Block other) {
    return this.x == other.x && this.y == other.y; 
  } 
  void move(int dx, int dy) {
    this.x += dx; 
    this.y += dy; 
  } 
  void rotateCCW(Point center) {

  } 
  void rotateCW(Point center) {
    this.rotateCCW(center); 
    this.rotateCCW(center); 
    this.rotateCCW(center); 
  } 
}

class Tetra {
  Point center;
  BSet blocks; 
  Tetra(Point center, BSet blocks) {
    this.center = center; 
    this.blocks = blocks; 
  }
  ... 
}

class BSet extends ArrayList<Block> {
  boolean contains(Block block) {
    if (this.size() != 0) 
      for (Block b : this)
        if (b.equals(block))
          return true;
    return false; 
  } 
  boolean subset(BSet other) {
    if (this.size() != 0)
      for (Block b : this)
        if (! other.contains(b))
          return false; 
    return true; 
  }
  boolean equals(BSet other) {
    return this.subset(other) && other.subset(this); 
  } 
  BSet intersect(BSet other) {
    ... 
  } 
  BSet union(BSet other) {

  } 
  int count() {
    return this.size(); 
  }
  int maxY() { ... }
  int minX() { ... }
  int maxX() { ... }
  void move(int dx, int dy) {

  } 
  void rotateCCW(Point center) { }
  void rotateCW(Point center) { }
  void changeColor(Color color) {

  }
  boolean overflow() {

  } 
  ...
}

class World { // class Tetris implements World { 
  Tetra falling;
  BSet blocks; 
  World(Tetra tetra, BSet blocks) {
    this.falling = tetra;
    this.blocks = blocks; 
  } 
}

Stage Two is collecting the specs for the four classes World, BSet, Tetra, Block. 

Then implementing them (draft) in Java. Do this for Wednesday. 

--