BallTest.java

/*
============================================================================
BallTest.java
This class uses the user defined object below called Ball.*/  


< applet
code=BallTest
width=200
height=200 >
< /applet >



===========================================================================
*/

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


public class BallTest extends Applet
{
	//Instance of Ball object
	Ball football = new Ball();
	//Text area for browser display
	TextArea ta = new TextArea(5,25);

	public void init()
	{
		//Set property values
		football.color="brown";
		football.material="pigskin";
		football.shape="oval";
		football.size="medium";
		//Display results on browser window
		ta.setText("Football object..."+"\n" +
		football+ "\n");
		add(ta);
	}
}

/*
=======================================================================
Ball.java
This is the Ball object used by BallTest.java
=======================================================================
*/
  
import java.applet.*;
import java.awt.*;
import java.io.*;


public class Ball extends Applet

{
	//Properties section
	String color="";
	String material="";
	String shape="";
	String size="";
	//Constructor method
	Ball()
	{
		color="";
		material="";
		shape="";
		size="";
	}
	//Methods section
	public void setColorValue(String iValue)
	{
		color = iValue;
	}
	public void setMaterialValue(String iValue)
	{
		material=iValue;
	}
	public void setShapeValue(String iValue)
	{
		shape = iValue;
	}
	public void setSizeValue(String iValue)
	{
		size=iValue;
	}
	
	
	public String toString()
	{
		return ("Color :" + color +
		"\n" +"Material:" +material+
		"\n" + "Shape :" +shape +
        "\n" + "Size :" +size +"\n");
	}
}


Output for BallTest.java