What is Stage Two of the project? 

Summarize it in three minutes. 

Alex D, Chris N, Thomas A, Dustin K, Laura H, Daniel O, Clayton T, Jake DiB, 
Nick F, Taylor P, Josh P, Jay K, Jeremy B, Andrzej K, Peng Pong Chen, David L, 
Andrew D, Anna McN, Yongtao C, Steve B, Ryan P, Josh M, Hao T, Caleb G, Adam K, 
Dimas M, Creighton H, Austin M, Joel P, Yangjun L, Maro R, Donovan M, Jacob C, 
Quintin L, Alex T, Omar W, Ethan Y, Troy S, Yingzhen Q, Zhengyu L, Rodrigo M V,
Will T, Rishu S, Megan H, Nikita H, Scott M, Qin N, Ethan Yitian Z, Angely R P, 
Chen Cheng (cc56), Shichao H, Seth Xiaohui W, Noah P, Joey R, Biao Z, Brittany H,
Samy R, Danny N


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); 
}

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) { } 
}

--

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); 
    frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
    game.start(); 
  }
}

Stage Two adds:

class Point {
  
}

class Block {
  
}

class SetOfBlocks {
  
}

class Tetromino {
  
}

class Utilities {

}

We also need to keep writing into Tetris. 

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

   private void drawSquare(Graphics g, int x, int y, Tetrominoes shape)
    {
        Color colors[] = { new Color(0, 0, 0), new Color(204, 102, 102), 
            new Color(102, 204, 102), new Color(102, 102, 204), 
            new Color(204, 204, 102), new Color(204, 102, 204), 
            new Color(102, 204, 204), new Color(218, 170, 0)
        };


        Color color = colors[shape.ordinal()];

        g.setColor(color);
        g.fillRect(x + 1, y + 1, squareWidth() - 2, squareHeight() - 2);

        g.setColor(color.brighter());
        g.drawLine(x, y + squareHeight() - 1, x, y);
        g.drawLine(x, y, x + squareWidth() - 1, y);

        g.setColor(color.darker());
        g.drawLine(x + 1, y + squareHeight() - 1,
                         x + squareWidth() - 1, y + squareHeight() - 1);
        g.drawLine(x + squareWidth() - 1, y + squareHeight() - 1,
                         x + squareWidth() - 1, y + 1);
    }


So we end up with 

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) { } 
}

import java.awt.*; 

class Block { 
  final static int SIZE = 20; // in pixels 
  final static int ROWS = 20; // in blocks 
  int x, y; 
  Color color; 
  Block(int x, int y, Color c) {
    this.x = x;
    this.y = y;
    this.color = c;
  }
  void draw(Graphics g) { // block->image
//           (+ (* (block-x b) block-size) (/ block-size 2))
//           (+ (* (block-y b) block-size) (/ block-size 2))
    int xp = this.x * SIZE, 
        yp = SIZE * ROWS - this.y * SIZE; 
    g.setColor(this.color);
    g.fillRect(xp, yp, SIZE, SIZE); 
    g.setColor(Color.BLACK);
    g.drawRect(xp, yp, SIZE, SIZE);     
  } 
}

class Point {
  
}

import java.awt.*; 

class SetOfBlocks extends ArrayList<Block> {
  void draw(Graphics g) { // blocks->image
    for (Block b : this)
      b.draw(g); 
  }
}

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

class Tetris implements World {
  public void draw(Graphics g) { // world->image
    System.out.println("World being drawn."); 
    g.drawString("Welcome to Tetris.", 100, 200); 
    /*
    Block b0 = new Block(0, 0, new Color(255, 255, 0));
    Block b1 = new Block(1, 1, new Color(255, 255, 0));
    Block b2 = new Block(2, 2, new Color(255, 255, 0));
    Block b3 = new Block(3, 3, new Color(255, 255, 0));
    Block b4 = new Block(4, 4, new Color(255, 255, 0));
    Block b5 = new Block(5, 5, new Color(255, 255, 0));
    Block b6 = new Block(6, 6, new Color(255, 255, 0));
    Block b7 = new Block(7, 7, new Color(255, 255, 0));
    b0.draw(g); 
    b1.draw(g); 
    b2.draw(g); 
    b3.draw(g); 
    b4.draw(g); 
    b5.draw(g); 
    b6.draw(g); 
    b7.draw(g); 
    Block b8  = new Block(8,  8, new Color(255, 255, 0));
    Block b9  = new Block(9,  9, new Color(255, 255, 0));
    Block b10 = new Block((int) (10 * Math.random()), 10, new Color(255, 255, 0));
    Block b11 = new Block((int) (10 * Math.random()), 11, new Color(255, 255, 0));
    Block b12 = new Block((int) (10 * Math.random()), 12, new Color(255, 255, 0));
    Block b13 = new Block((int) (10 * Math.random()), 13, new Color(255, 255, 0));
    Block b14 = new Block((int) (10 * Math.random()), 14, new Color(255, 255, 0));
    Block b15 = new Block((int) (10 * Math.random()), 15, new Color(255, 255, 0));
    Block b16 = new Block((int) (10 * Math.random()), 16, new Color(255, 255, 0));
    Block b17 = new Block((int) (10 * Math.random()), 17, new Color(255, 255, 0));
    Block b18 = new Block((int) (10 * Math.random()), 18, new Color(255, 255, 0));
    Block b19 = new Block((int) (10 * Math.random()), 19, new Color(255, 255, 0));
    b8.draw(g);
    b9.draw(g);
    b10.draw(g);
    b11.draw(g);
    b12.draw(g);
    b13.draw(g);
    b14.draw(g);
    b15.draw(g);
    b16.draw(g);
    b17.draw(g);
    b18.draw(g);
    b19.draw(g);
    */ 
    Tetromino t = new Tetromino(new Point(4, 3), ...);
  } 
  public void update() { System.out.println("World getting older."); }
  public boolean hasEnded() { return false; } 
  public void keyPressed(KeyEvent e) { // world-key-move 
    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(300, 460); 
    frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
    game.start(); 
  }
}

import java.awt.*; 

class Tetromino {
  Point center; 
  SetOfBlocks blocks; 
  Tetromino(Point c, SetOfBlocks s) {
    this.center = c;
    this.blocks = s; 
  }
  void draw(Graphics g) {
    this.blocks.draw(g);         
  }
}

class Utilities {
  static SetOfBlocks build-tetromino(String which) {
    if (which.equals("square")) {
      ... 
    } else return null; 
  }
}

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

interface World {
  public void draw(Graphics g); // world->image
  public void update(); 
  public boolean hasEnded();
  public void keyPressed(KeyEvent e); 
}

Now ghet a tetromino to show and you're done with Stage Two. 

--