Okay here is my question, I have an text file file which looks like this
BASKETBALL
John Jacob
58% 15points
FOOTBALL
Jason Smith
24% 1touchdown
BASKETBALL
Mark Ramos
23% 25points
BASEBALL
Isaac David
10% 2 homeruns
FOOTBALL
David Sarlo
10% 0 touchdowns
I am attempting to take a list like this and output something like this in a console and text file.
Sport: Name Stats
BASKETBALL John Jacob 58% 15points
BASKETBALL Mark Ramos 23% 25points
BASEBALL Isaac David 10% 2 homeruns
FOOTBALL Jason Smith 24% 1touchdown
FOOTBALL David Sarlo 10% 0 touchdowns
I was thinking that I could have the buffer reader to read the file. Right after that I am not sure what to do, I am thinking to read the line then compare it to BASKETBALL, FOOTBALL or BASEBALL string then add it to the appropriate array does that sound right? I am trying to create a new Basketball player football player and baseball player, who as certain attributes. I guess I have multiple questions, how do I get the next line in to match up with the correct player. Then move to the next line and do the same?
import java.io.*;
private static String[] basketball = new String[100];
private static String[] football = new String[100];
private static String[] baseball = new String[100];
public static void CreateTeamList()
{
BufferedReader in = new BufferedReader (new FileReader(fileName));
try {
while (line ! = null)
{
String line = in.readline();
if (line == "BASKETBALL")
{
create new BasketnallPlayer;
}
if (line == "FOOTBALL")
{
create new FootballPlayer;
}
if (line == "BASEBALL")
{
create new BaseballPlayer;
}
}