// cube.java
// Show how to set up a 3D object 

import java.applet.*;   		// applet classes
import java.awt.*;			// user interface classes
import java.awt.event.*;		// event handling classes
import java.io.*;			// for screen I/O

public class cube extends Applet {

	int [] x;
	int [] y;
	int [] z;
	int size = 100;
	int upperleftx = size;
	int upperlefty = size;
	int upperleftz = size;
	int delay = 200;
	Color myColor, myColor2;

	public void paint (Graphics grafObj) {
		int i, j;

		grafObj.setColor (myColor);
		// front
		for (i = 0; i < 3; i++) 
			grafObj.drawLine (x[i], y[i], x[i+1], y[i+1]);
		grafObj.drawLine (x[3], y[3], x[0], y[0]);
		// back
		for (i = 4; i < 7; i++) 
			grafObj.drawLine (x[i], y[i], x[i+1], y[i+1]);
		grafObj.drawLine (x[7], y[7], x[4], y[4]);
		// sides
		for (i = 0, j = 4; j < 8; i++, j++)  
			grafObj.drawLine (x[i], y[i], x[j], y[j]);
	}  // paint


	public void init () {
		// using left-handed system
		int i;
	
		x = new int [8];
		y = new int [8];
		z = new int [8];

		// front plane
		x[0] = upperleftx;
		y[0] = upperlefty;
		z[0] = upperleftz;

		x[1] = upperleftx + size;
		y[1] = upperlefty;
		z[1] = upperleftz;

		x[2] = upperleftx + size;
		y[2] = upperlefty + size;
		z[2] = upperleftz;

		x[3] = upperleftx;
		y[3] = upperlefty + size;
		z[3] = upperleftz;

		// back plane
		x[4] = upperleftx;
		y[4] = upperlefty;
		z[4] = upperleftz + size;

		x[5] = upperleftx + size;
		y[5] = upperlefty;
		z[5] = upperleftz + size;

		x[6] = upperleftx + size;
		y[6] = upperlefty + size;
		z[6] = upperleftz + size;

		x[7] = upperleftx;
		y[7] = upperlefty + size;
		z[7] = upperleftz + size;

		// blueish
		myColor = new Color (100, 0, 255);
	}  // init
}  // program
