I have a constructor in a class called Sport
public Sport(String i_sportName,int i_usagefee, int i_insurance, int i_affiliation, ArrayList<Integer> i_courtNo)
I'm wondering how I would pass information read from a textfile from another class called Club into the constructor of Sport that has the format :
//name,usagefee,affilfee,userfee,courtno Tennis,12,44,23,12,13,15,6,7
This is my current code to load the text file
public void loadSports()
{
try
{
FileReader input = new FileReader("location/sports.txt");
BufferedReader br = new BufferedReader(input);
String line;
String result;
String delims = ",";
System.out.print("\f");
sports = new ArrayList<Sport>();
ArrayList<Integer>courtNo = new ArrayList<Integer>();
while((line=br.readLine())!=null)
{
//System.out.println(line);
String[] linearr = line.split(delims);
for(int i=0;i<linearr.length;i++)
{
System.out.println(linearr[0]);
//Sport sports = new Sport(linearr[0],linearr[1],linearr[2],linearr[3],courtNo.add(1,2,3,4));
}
}
input.close();
}
catch(IOException e)
{
e.printStackTrace();
}
}