Hi there
great sight iv been reading and learning from alot of the questions here.
iv just started programming using java... we use Bluej at uni.
my problem is as follows:
i have 2 classes. the 1st class is called soldiers and creates objects called soldiers and stores their attributes, eg name, id number, rank etc...
The second class is taskForce which stores which has an add method and adds soldiers to the task force by storing them in an arrayList
the method i need to create now is a list method but the list method must only list those soldiers which share the same attribute, eg rank
The only way i know how to list some thing is:
public void listSoldiers()
{
System.out.println(toString());
}
im presuming something like:
public void ListByRank(String sRank)
{
for(Soldier soldier : taskForce)
{
System.out.println(toString());
}
}
not sure on the rest if some one could point me in the right direction it would be a great help.