// 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; 

public class Snake {
  private String name;
  private int x, y; 
  private String direction = "Nowhere";
  public void face(String direction) {
    this.direction = direction;      
  }
  public Snake(String name) {
    this.name = name;  
    this.x = 120; 
    this.y = 70;
    this.direction = "East";
  }
  public void draw(Graphics g) {
    g.drawString(name, this.x, this.y); 
  }
  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;
  }
}

https://www.cs.indiana.edu/classes/c212-dgerman/fall2016/hw07/image001.jpg


[serepate@silo ~]$ ls
bin  c211sum2018  h212-sum2018-workspace  README
[serepate@silo ~]$ cd h212-sum2018-workspace/
[serepate@silo h212-sum2018-workspace]$ cat .setup
JAVA_HOME=/usr/lib/jvm/java-1.7.0
export JAVA_HOME

CATALINA_HOME=/u/serepate/h212-sum2018-workspace/apache-tomcat-7.0.35
export CATALINA_HOME

JUNIT_HOME=~/h212-sum2018-workspace/JUNIT
export JUNIT_HOME

CLASSPATH=.:$CATALINA_HOME/lib/servlet-api.jar:$JUNIT_HOME/junit-4.10.jar
export CLASSPATH

[serepate@silo h212-sum2018-workspace]$ source .setup
[serepate@silo h212-sum2018-workspace]$ cd $CATALINA_HOME
[serepate@silo apache-tomcat-7.0.35]$ clear
[serepate@silo apache-tomcat-7.0.35]$ ls
bin  conf  lib  LICENSE  logs  NOTICE  RELEASE-NOTES  RUNNING.txt  temp  webapps  work
[serepate@silo apache-tomcat-7.0.35]$ cd webapps/
[serepate@silo webapps]$ ls
docs  examples  host-manager  manager  ROOT  stageThree  stageTwo
[serepate@silo webapps]$ mkdir monday
[serepate@silo webapps]$ mkdir monday/WEB-INF
[serepate@silo webapps]$ mkdir monday/WEB-INF/classes
[serepate@silo webapps]$ mkdir monday/WEB-INF/src
[serepate@silo webapps]$ mkdir monday/WEB-INF/lib
[serepate@silo webapps]$ touch monday/index.html
[serepate@silo webapps]$ touch monday/WEB-INF/web.xml
[serepate@silo webapps]$ tree monday/
monday/
+-- index.html
+-- WEB-INF
    +-- classes
    +-- lib
    +-- src
    +-- web.xml

4 directories, 2 files
[serepate@silo webapps]$ touch monday/whatever.jsp
[serepate@silo webapps]$ touch monday/WEB-INF/src/Something.java
[serepate@silo webapps]$ tree monday/
monday/
+-- index.html
+-- WEB-INF
|   +-- classes
|   +-- lib
|   +-- src
|   |   +-- Something.java
|   +-- web.xml
+-- whatever.jsp

4 directories, 4 files
[serepate@silo webapps]$


http://silo.cs.indiana.edu:27191/monday/

http://silo.cs.indiana.edu:27191/monday/whatever.jsp

[serepate@silo monday]$ pwd
/u/serepate/h212-sum2018-workspace/apache-tomcat-7.0.35/webapps/monday
[serepate@silo monday]$ nano -w whatever.jsp
[serepate@silo monday]$ ls -l
total 8
-rw------- 1 serepate students 21 Jul 23 15:20 index.html
drwx------ 5 serepate students 59 Jul 23 15:20 WEB-INF
-rw------- 1 serepate students 74 Jul 23 15:24 whatever.jsp
[serepate@silo monday]$ cat whatever.jsp
I am a JSP. <p>

The time is: <% out.println( new java.util.Date() ); %>
[serepate@silo monday]$


* mahazuga: Mary Ann
* serepate: Serena
  hgarciah: Henri
  balbakr: Bakr
* ruifan: Rui
* mzelenin: Matthew
* jnp2: Jay
* zeyang: Zejun
* zhang486: Jingyun
  yiwecao: Yiwei
* rthammon: Ryan
* wang686: Jiaxing
* dweissma: Andrew
* kevcao: Kevin
* ssalmero: Salmeron, Santiago (TA)
* luo23: Yawen
* runxzhao: Runxia
* dgerman: German, Dan-Adrian (Primary Instructor)
  creba: Chris