[ create a new paste ] login | about

Link: http://codepad.org/tsYrOKyy    [ raw code | fork ]

Plain Text, pasted on Apr 7:
import java.util.*; 
import java.io.*; 

public class Prog6
{
	public static void main(String[] args)
	{
		String fName; 
		String lName; 
		String position; 
		String team;
		int completions; 
		int attempts; 
		int yards; 
		int receptions;
		final int MAX_PLAYERS = 20; 
		
		
		Scanner inFile = null; 
		Player players[] = new Player[MAX_PLAYERS];
		
		try
		{
			inFile = new Scanner( new File ( "nfl.txt" ) );
		}
		catch( FileNotFoundException e)
		{
			System.err.println( "Error: file not found" );
		}
		
		while( inFile.hasNext() )
		{
			fName = inFile.next();
			lName = inFile.next();
			team = inFile.next();
			position = inFile.next();
			
			if( position.equals("QB") )
			{
				completions = inFile.nextInt();
				attempts = inFile.nextInt();
				yards = inFile.nextInt();
			}
			else
			{
				receptions = inFile.nextInt();
				yards = inFile.nextInt();
			}
			
			
			for(int i = 0; i < players.length ; i++)
			{
				if( players[i] instanceof Quarterback )
				{
					System.out.println( players[i].getfName() + players[i].getlName() + players[i].getTeam() + players[i].getPosition() + ( (Quarterback) players[i]).getCompletions() + (( Quarterback ) players[i]).getAttempts() + ((Quarterback) players[i]).getYards());	
				}
			}
			
			for( int j = 0; j < players.length ; j++)
			{
				if( players[j] instanceof Receiver)
				{
					System.out.println( players[j].getfName() + players[j].getlName() + players[j].getTeam() + players[j].getPosition() + ((Receiver) players[j]).getReceptions() + ((Receiver) players[j]).getYards());
				}
			}
		}
	
	}

}


Create a new paste based on this one


Comments: