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

public class Test
{
	public static void main( String args[] )
	{
		// Create Doubley linked Circular list of data type circle.
		CircleDCList myCircleList = new CircleDCList();
		System.out.println("Declared CircleDCList");
		// Set the radius on the inital circle.
		// Note this direct assignment should be done via a method.
		//myCircleList.currentCircle.circleData.radius = 10.0;

		// Insert more circles.
		// Again these should be done via methods or constructors
		//myCircleList.InsertCircle();					//Exception Here
		//myCircleList.currentCircle.circleData.radius = 20.0;
		//myCircleList.InsertCircle();
		//myCircleList.currentCircle.circleData.radius = 30.0;
		//myCircleList.InsertCircle();
		//myCircleList.currentCircle.circleData.radius = 40.0;

		// Reset to the head of the list.
		myCircleList.Reset();
		System.out.println("Reset to head");
		// Print the radius of the head element.
		//System.out.println("Radius = " + myCircleList.currentCircle.circleData.radius);
		// Increment to the next element in the list.
		//myCircleList.NextCircle();
		// Print the radius of the second element.
		//System.out.println("Radius = " + myCircleList.currentCircle.circleData.radius);

	}
}
class CircleDCList
{
	public void CircleDCList()
	{
		// Create the head element on creation of the list.
		CircleElement headCircle = new CircleElement();
		// Set all the "pointers".
		// Since no other CircleElements exist they must point at the headCircle.
		this.headCircle = headCircle;
		this.currentCircle = headCircle;
		this.currentCircle.nextCircle = headCircle;
		this.currentCircle.previousCircle = headCircle;
		System.out.println("CircleDCList created:");
	}
	public CircleElement CurrentCircle()
	{
		// Return the current circleElement.
		return( this.currentCircle );
	}

	public CircleElement NextCircle()
	{
		// Increment the currentCircle pointer to point at the next Circle.
		this.currentCircle = this.currentCircle.nextCircle;
		// Return the new currentCircle.
		return( this.currentCircle );
	}

	public CircleElement PreviousCircle()
	{
		// Decrement the currentCircle pointer to point at the previous Circle.
		this.currentCircle = this.currentCircle.previousCircle;
		// Return the new currentCircle.
		return( this.currentCircle );
	}

	public CircleElement Reset()
	{
		// Reset the currentCircle "pointer" to the headCircle.
		this.currentCircle = this.headCircle;
		// Return the new currentCircle.
		return( this.currentCircle );
	}

	public CircleElement InsertCircle()
	{
		// Create a new circleElement to insert.
		CircleElement insertionCircleElement = new CircleElement();
		// Set the insertionCircleElement's nextCircle and previousCircle
		// pointers to point at the currentCircle and the nextCircle.
		insertionCircleElement.previousCircle = this.currentCircle;
		insertionCircleElement.nextCircle = this.currentCircle.nextCircle;	//Exception here
		// Set the currentCircle to the new insertionCircleElement.
		this.currentCircle = insertionCircleElement;

		// Set the nextCircle's previousCircle pointer to point at
		// the new insertionCircleElement.
		this.currentCircle.nextCircle.previousCircle = insertionCircleElement;
		// Set the previousCircle's nextCircle pointer to point at
		// the new insertionCircleElement.
		this.currentCircle.previousCircle.nextCircle = insertionCircleElement;

		return( this.currentCircle );
	}

	public CircleElement DeleteCircle()
	{
		// Not implemented yet
		return( this.currentCircle );
	}

	public boolean IsHead()
	{
		// Not implemented yet
		return( false );
	}

	CircleElement headCircle;		// List head pointer.
	CircleElement currentCircle;		// Current list element pointer.
}

class CircleElement
{
	public void CircleElement()
	{
		// Default CircleElement constructor.
		// Create a new default Circle to point at.
		Circle defaultCircle = new Circle();
		// Set the new CircleElement's values.
		this.circleData = defaultCircle;
		// No other CircleElements known yet so point at this.
		this.nextCircle = this;
		this.previousCircle = this;
		System.out.println("CircleElement created: Default");
	}
	public void CircleElement( Circle predefinedCircle )
	{
		// Construct a CircleElement for an existing Circle.
		this.circleData = predefinedCircle;
		// No other CircleElements known yet so point at this.
		this.nextCircle = this;
		this.previousCircle = this;
		System.out.println("CircleElement created: Predefined");
	}

	Circle		circleData;		// Circle Data
	CircleElement	nextCircle;		// Next CircleElement in the list.
	CircleElement	previousCircle;		// Previous CircleElement in the list.
}

class Circle
{
	public void Circle()
	{
		// Default Circle constructor.
		this.radius = 0.0;
		this.xPosition = 0.0;
		this.yPosition = 0.0;
		System.out.println("Circle created: Default");
		System.out.println("radius = " + this.radius);
		System.out.println("xPosition = " + this.xPosition);
		System.out.println("yPosition = " + this.yPosition);

	}
	public void Circle( double r, double x, double y )
	{
		// Constructor for Circle of given dimensions.
		this.radius = r;
		this.xPosition = x;
		this.yPosition = y;
		System.out.println("Circle created: given dimensions");
		System.out.println("radius = " + this.radius);
		System.out.println("xPosition = " + this.xPosition);
		System.out.println("yPosition = " + this.yPosition);
	}

	double     radius;
	double     xPosition;
	double     yPosition;
}
