Advertisement
INSECURE-FLOWERPOT

Untitled

Mar 27th, 2015
220
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.34 KB | None | 0 0
  1. import javax.swing.*;
  2. import java.util.*;
  3. /**
  4. * The Team class is used for storing information on a single team.
  5. *
  6. */
  7. public class Team
  8. {
  9. /**Stores the name of the team.**/
  10. private String name;
  11.  
  12. /**Stores the home city of the team.**/
  13. private String city;
  14.  
  15. /**Stores the home state of the team.**/
  16. private String state;
  17.  
  18. /**Stores the latitude and longitude of the home city of the team.**/
  19. private String location;
  20.  
  21. /**Stores a list of team players.**/
  22. private ArrayList<String>roster = new ArrayList<String>();
  23.  
  24. /**Stores keys, team birth cities, and values, birth city latitudes and longitudes.**/
  25. private HashMap<String,String>birthCitiesPoints = new HashMap<String,String>();
  26.  
  27. private ArrayList<String>people=new ArrayList<String>();
  28.  
  29. /**
  30. * The constructor for Team class.
  31. * @param name Passes in the teams name.
  32. * @param city Passes in the teams home city.
  33. * @param state Passes in the teams home state.
  34. * @param roster Passes a list of team players.
  35. */
  36. public Team(String name, String city, String state, ArrayList<String>roster,ArrayList<String>people)
  37. {
  38. this.name=name;
  39. this.city=city;
  40. this.state=state;
  41. this.roster=roster;
  42. this.people=people;
  43. }
  44.  
  45. /**
  46. * The getTeamNames() is an accessor method that returns the teams name.
  47. * @return Returns the teams name.
  48. */
  49. public String getTeamName()
  50. {
  51. return name;
  52. }
  53.  
  54. /**
  55. * The getTeamCity() is an accessor method that returns the teams home city.
  56. * @return Returns the teams home city.
  57. */
  58. public String getTeamCity()
  59. {
  60. return city;
  61. }
  62.  
  63. /**
  64. * The getTeamState() is an accessor method that returns the teams home state.
  65. * @return Returns the teams home state.
  66. */
  67. public String getTeamState()
  68. {
  69. return state;
  70. }
  71.  
  72. /**
  73. * The displayTeamMethod() creates a JFrame for a map of the United States to be displayed with team members birth cities.
  74. * @param locations passes in a list of player names and corresponding latitudes and longitudes.
  75. */
  76. public void displayTeamMap(HashMap<String,String>locations)
  77. {
  78. JFrame frame =new JFrame("Birth Cities of Team Players");
  79. frame.setBounds(0,0,650,500);
  80.  
  81. HashMap<String,String>pass=new HashMap<String,String>();
  82. if(locations.containsKey((city+state)))
  83. {
  84. String latLong=locations.get((city+state));
  85. String[]tokens=latLong.split("[,]");
  86. if(tokens.length == 2)
  87. {
  88. double lat = Double.parseDouble(tokens[0]);
  89. double lon=Double.parseDouble(tokens[1].substring(1));
  90. if(!roster.isEmpty()&&!locations.isEmpty()&&!people.isEmpty())
  91. {
  92. if(roster.size()<=locations.size())
  93. {
  94. for(int i=0; i<roster.size(); i++)
  95. {
  96. String[]peopTokens=people.get(i).split(",");
  97. if(peopTokens.length == 4 || peopTokens.length == 5)
  98. {
  99. int x=-1;
  100. for(int j=0; j<roster.size(); j++)
  101. {
  102. if(tokens[0].compareTo(roster.get(j))==0)
  103. {
  104. x=j;
  105. break;
  106. }
  107. }
  108.  
  109. if(x>=0)
  110. {
  111. if(locations.containsKey(tokens[2]+tokens[3]))
  112. {
  113. String loc=locations.get(tokens[2]+tokens[3]);
  114. pass.put(tokens[0],loc);
  115. TeamMap tm = new TeamMap(name,lat,lon,people,pass);
  116. }
  117. }
  118. }
  119. }
  120. }
  121. }
  122. }
  123. }
  124.  
  125.  
  126.  
  127.  
  128.  
  129. }
  130. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement