* mahazuga: Mary Ann

All stages fine. 

* serepate: Serena

All stages fine. 

  hgarciah: Henri

Dropped. 

* balbakr: Bakr

Stage 01 fine.

Stage 02 and Stage 03 missing. 

* ruifan: Rui

All stages are fine. 

* mzelenin: Matthew

All stages fine. 

* jnp2: Jay

All stages fine. 

* zeyang: Zejun

All stages fine. 

* zhang486: Jingyun

All stages fine.

  yiwecao: Yiwei

Stage 01 good, 02 and 03 missing. 

* rthammon: Ryan

All stages fine. 

* wang686: Jiaxing

Everything fine, Stage Three a bit off. 

* dweissma: Andrew

Good, all three stages. 

* kevcao: Kevin

Stage 01, 02 and 03: fine. 

* ssalmero: Salmeron, Santiago (TA)

N/A

* luo23: Yawen

All stages fine. 

  runxzhao: Runxia

All stages fine. 

* dgerman: German, Dan-Adrian (Primary Instructor)

N/A though stages posted. 

  creba: Chris

Server not up. 

--

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); 
  public void mousePressed(MouseEvent e); 
}

--

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

class BigBang extends JComponent implements KeyListener, ActionListener, MouseListener {
  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); 
    this.repaint(); 
  } 
  public void keyTyped(KeyEvent e) { } 
  public void keyReleased(KeyEvent e) { } 

  public void mousePressed(MouseEvent e) { 
    world.mousePressed(e); 
    this.repaint(); 
  } 
  public void mouseReleased(MouseEvent e) { } 
  public void mouseClicked(MouseEvent e) { } 
  public void mouseEntered(MouseEvent e) { } 
  public void mouseExited(MouseEvent e) { } 

}

--

These parts have in fact not been changed. 

They represent the framework. 


--

import java.awt.Graphics;
  
public class Circle {
  private int x, y, radius;
  public Circle(int x, int y, int r) {
    this.x = x; 
    this.y = y; 
    this.radius = r; 
  }
  public void draw(Graphics g, int x, int y) {
    this.x = x;
    this.y = y; 
    g.drawOval(this.x, this.y, this.radius * 2, this.radius * 2);  
  }
  public void draw(Graphics g) {
    g.drawOval(this.x, this.y, this.radius * 2, this.radius * 2);  
  }
}

// Game.java 

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

public class Game implements World {
  Snake snake; 
  public Game() {
    this.snake = new Snake("Larry");  
  }
  public void update() {
    this.snake.move(); 
  }
  public void draw(Graphics g) {
    this.snake.draw(g); 
  }
  public void mousePressed(MouseEvent e) { 
  
  } 
  public void keyPressed(KeyEvent e) { 
    // System.out.println( e ); // user responsibility 
    int code = e.getKeyCode(); 
    if (code == 37) { // left 
      this.snake.face("West");
    } else if (code == 38) { // up 
      this.snake.face("North");
    } else if (code == 39) { // right
      this.snake.face("East");
    } else if (code == 40) { // down
      this.snake.face("South");
    } else {
      this.snake.face("Nowhere");
    }
  }
  public static void main(String[] args) {
    BigBang game = new BigBang(30, new Game());  

    JFrame frame = new JFrame("Game"); 

    frame.getContentPane().add( game ); 

    game.addMouseListener( game ); 
    frame.addKeyListener( game ); // user responsibility
    
    frame.setVisible(true); 
    frame.setSize(400, 400); 
    // frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE ); 
    game.start(); 
  }
  public boolean hasEnded() {
    return false; // never!! 
  }
}

import java.awt.Graphics; 
import java.util.ArrayList; 

public class Snake {
  private String name;
  private int x, y; 
  private String direction = "Nowhere";
  public void face(String direction) {
    this.direction = direction;      
  }
  Circle head; 
  ArrayList<Circle> body; 
  private int RADIUS =  10; 
  public Snake(String name) {
    this.name = name;  
    this.x = 120; 
    this.y = 70;
    this.direction = "Nowhere";
    this.head = new Circle(this.x, this.y, RADIUS); 
    this.body = new ArrayList<Circle>(); 
    this.body.add(new Circle(this.x + 2 * RADIUS, this.y - 0 * RADIUS, RADIUS)); 
    this.body.add(new Circle(this.x + 4 * RADIUS, this.y - 0 * RADIUS, RADIUS)); 
    this.body.add(new Circle(this.x + 6 * RADIUS, this.y - 0 * RADIUS, RADIUS)); 
    this.body.add(new Circle(this.x + 6 * RADIUS, this.y + 2 * RADIUS, RADIUS)); 
    this.body.add(new Circle(this.x + 6 * RADIUS, this.y + 4 * RADIUS, RADIUS)); 
    this.body.add(new Circle(this.x + 8 * RADIUS, this.y + 4 * RADIUS, RADIUS)); 
    this.body.add(new Circle(this.x + 8 * RADIUS, this.y + 6 * RADIUS, RADIUS)); 
    this.body.add(new Circle(this.x + 8 * RADIUS, this.y + 8 * RADIUS, RADIUS)); 
    this.body.add(new Circle(this.x + 6 * RADIUS, this.y + 8 * RADIUS, RADIUS)); 
    this.body.add(new Circle(this.x + 4 * RADIUS, this.y + 8 * RADIUS, RADIUS)); 
    this.body.add(new Circle(this.x + 2 * RADIUS, this.y + 8 * RADIUS, RADIUS)); 
    this.body.add(new Circle(this.x + 2 * RADIUS, this.y + 6 * RADIUS, RADIUS)); 
  }
  public void draw(Graphics g) {
    g.drawString(name, this.x, this.y); 
    this.head.draw( g, this.x, this.y ); 
    for (Circle c : this.body)
      c.draw(g); 
  }
  public void move() {
    if (this.direction.equals("East" )) this.x += 3; 
    if (this.direction.equals("West" )) this.x -= 3;
    if (this.direction.equals("North")) this.y -= 3;
    if (this.direction.equals("South")) this.y += 3;

    if (this.direction.equals("East" )) this.x += 3;
    if (this.direction.equals("West" )) this.x -= 3;
    if (this.direction.equals("North")) this.y -= 3;
    if (this.direction.equals("South")) this.y += 3;
  }
}

--