/* More practice with methods and intro to arrays */ package seventhfall16; import java.io.File; import java.io.FileNotFoundException; import java.util.Scanner; /** * * @author jcmtiernan */ public class SeventhFall16 { /** * @param args the command line arguments */ public static void main(String[] args) { Scanner input = new Scanner(System.in); Scanner inFile; File inputData = new File("src/seventhfall16/TeamsIn4Seventh"); try { inFile = new Scanner(inputData); } catch (FileNotFoundException fnf) { inFile = new Scanner(System.in); System.out.println("Can't find input file"); System.out.println(); System.out.println("Please enter an FTC team number followed by the team name. Separate these with a space. \n" + " Enter -1 for the team number if you are finished entering teams."); } int team1 = 127; int team2 = 3697; int team3 = 4745; int team4 = 7172; int team5 = 6169; int team6 = 10044; int team7 = 10443; int team8 = 201601234; int[] teams = new int[100]; teams[0] = 4001; teams[1] = 9687; teams[7] = 3214; teams[8] = 987; teams[4] = 1276; teams[5] = 6748; teams[6] = 3715; teams[9] = 887; String team1Name = "Fighting Pickles"; String team2Name = "Devastatorz"; String team3Name = "Thorn's Army"; String team4Name = "Techinical Difficulties"; String team5Name = "Men in Black"; String team7Name = "Tech Vikes"; String team6Name = "Mecha Men"; team8 = 12000; String[] teamNames =new String[100]; teamNames[0] = "Robotic Cows of Death"; teamNames[1] = "Corncobs"; teamNames[7] = "Ratchet and Clank"; teamNames[8] = "Big Hero 987"; teamNames[4] = "People"; teamNames[5] = "Pandemonium"; teamNames[6] = "Orozco's Army"; teamNames[9] = "TS"; // Modify program to read in team names and numbers int done = 0; for(int i = 0; (i < 100) && (done != -1) && (inFile.hasNextInt()); i++) { done = inFile.nextInt(); if (done != -1) { //System.out.println("In loop to read from file"); teams[i] = done; teamNames[i] = inFile.nextLine(); while (teamNames[i].charAt(0) == ' ') { teamNames[i] = teamNames[i].substring(1); //System.out.println("Removing blank in name["+i+"]"); } } } /* int[] scores = new int[10]; int rankings[] = {1,2,3,4,5,6,7,8}; System.out.println("The length of scores array is "+scores.length + " and rankings array is "+rankings.length); for (int index = 0; index < 8 ; index++) { System.out.println("scores["+index+"] is "+scores[index]); System.out.println("rankings["+index+"] is "+rankings[index]); } */ // Print matching team numbers and names /* if ((team1 > 0) && (team1 < 20000)) { System.out.println("Team number is "+team1 +" and team name is "+team1Name); } if ((team2 > 0) && (team2 < 20000)) { System.out.println("Team number is "+team2 +" and team name is "+team2Name); } if ((team3 > 0) && (team3 < 20000)) { System.out.println("Team number is "+team3 +" and team name is "+team3Name); }*/ /* printTeamBanner(team1, team1Name); printTeamBanner(team2, team2Name); printTeamBanner(team3, team3Name); printTeamBanner(team4, team4Name); //printTeamBanner(3, ""); System.out.println("****"); */ for (int index = 0; index < teams.length ; index++) { System.out.print("At iindex ["+index+"] "); printTeamBanner(teams[index],teamNames[index]); } } public static void printTeamBanner(int teamNum, String teamName) { if ((teamNum > 0) && (teamNum < 20000)) { System.out.println("Team number is "+teamNum +" and team name is "+teamName); } } }