Assignment 6: An animation of alien activity

In this assignment, you create an applet that behaves the same as the one below.

>
It comprises the following principal objects:

import java.awt.*;

public abstract class Alien {
    int x, y,       // location of alien
        size;       // size of alien
    Color color;    // color of alien
    final static int boardSize = 200,
                     xBoard = 50,
                     yBoard = 50;

// Constructor: initialize x and y to a random position inside the board, so that the even // the biggest alien gets drawn completely inside the board.
    public Alien()  { }
 
    // compute coordinates of next position of alien
    abstract void move();

    // draw alien at his location within the universe
    abstract void draw(Graphics g);
}




// Basic Assignment 6

import java.awt.*;
import java.applet.*;

public class animations extends Applet {
    int sleepTime = 80,     // time step between repaints
    // insert the other applet variables here

    // initialize applet
    public void init() {}
 
                // paint accomplishes the animation
    public void paint(Graphics g) {
       // draw the bounding box of the universe and all the aliens

        try {
            Thread.sleep(sleepTime);
        }
        catch (InterruptedException e) {
            showStatus(e.toString());
        }
        repaint();
    }

    public boolean action(Event event, Object o) {

        // process the button being clicked, then  ....
        repaint();
        return true;
    }
}




<HTML>
<HEAD>
<TITLE> A simple program </TITLE>
</HEAD>
<BODY>
<APPLET CODE="animations.class" WIDTH=400 HEIGHT=400></APPLET>
</BODY>
</HTML>

Turn In Procedure

Use email to turn in your code to cs10@cs.ucsb.edu.  Each class is a separate attachment within the same message.  Submit a hard copy to the CS10 homework box.