
Thecount2
By:
ace on
May 5th, 2010 | syntax:
None | size: 1.36 KB | hits: 27 | expires: Never
import java.util.ArrayList;
/**
* Write a description of class TheCount here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class TheCount
{
// instance variables - replace the example below with your own
private ArrayList <String> counter;
/**
* Constructor for objects of class TheCount
*/
public TheCount()
{
// initialise instance variables
counter = new ArrayList<String>();
}
private void fillCount(int index, String count)
{
counter.add(0, "one");
counter.add(1, "two");
counter.add(2, "three");
counter.add(3, "four");
counter.add(4, "five");
counter.add(5, "six");
counter.add(6, "seven");
counter.add(7, "eight");
counter.add(8, "nine");
counter.add(9, "ten");
}
/**
* An example of a method - replace this comment with your own
*
* @param y a sample parameter for a method
* @return the sum of x and y
*/
public int tenTo10(String count)
{
int index = 0;
while (index <= 8)
{
if (counter.get(index).contentEquals(count))
{
System.out.println (index+1);
return index+1;
}
index++;
}
return 0;
}
}