Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import javax.swing.*;
- import java.util.*;
- /**
- * The Team class is used for storing information on a single team.
- *
- */
- public class Team
- {
- /**Stores the name of the team.**/
- private String name;
- /**Stores the home city of the team.**/
- private String city;
- /**Stores the home state of the team.**/
- private String state;
- /**Stores the latitude and longitude of the home city of the team.**/
- private String location;
- /**Stores a list of team players.**/
- private ArrayList<String>roster = new ArrayList<String>();
- /**Stores keys, team birth cities, and values, birth city latitudes and longitudes.**/
- private HashMap<String,String>birthCitiesPoints = new HashMap<String,String>();
- private ArrayList<String>people=new ArrayList<String>();
- /**
- * The constructor for Team class.
- * @param name Passes in the teams name.
- * @param city Passes in the teams home city.
- * @param state Passes in the teams home state.
- * @param roster Passes a list of team players.
- */
- public Team(String name, String city, String state, ArrayList<String>roster,ArrayList<String>people)
- {
- this.name=name;
- this.city=city;
- this.state=state;
- this.roster=roster;
- this.people=people;
- }
- /**
- * The getTeamNames() is an accessor method that returns the teams name.
- * @return Returns the teams name.
- */
- public String getTeamName()
- {
- return name;
- }
- /**
- * The getTeamCity() is an accessor method that returns the teams home city.
- * @return Returns the teams home city.
- */
- public String getTeamCity()
- {
- return city;
- }
- /**
- * The getTeamState() is an accessor method that returns the teams home state.
- * @return Returns the teams home state.
- */
- public String getTeamState()
- {
- return state;
- }
- /**
- * The displayTeamMethod() creates a JFrame for a map of the United States to be displayed with team members birth cities.
- * @param locations passes in a list of player names and corresponding latitudes and longitudes.
- */
- public void displayTeamMap(HashMap<String,String>locations)
- {
- JFrame frame =new JFrame("Birth Cities of Team Players");
- frame.setBounds(0,0,650,500);
- HashMap<String,String>pass=new HashMap<String,String>();
- if(locations.containsKey((city+state)))
- {
- String latLong=locations.get((city+state));
- String[]tokens=latLong.split("[,]");
- if(tokens.length == 2)
- {
- double lat = Double.parseDouble(tokens[0]);
- double lon=Double.parseDouble(tokens[1].substring(1));
- if(!roster.isEmpty()&&!locations.isEmpty()&&!people.isEmpty())
- {
- if(roster.size()<=locations.size())
- {
- for(int i=0; i<roster.size(); i++)
- {
- String[]peopTokens=people.get(i).split(",");
- if(peopTokens.length == 4 || peopTokens.length == 5)
- {
- int x=-1;
- for(int j=0; j<roster.size(); j++)
- {
- if(tokens[0].compareTo(roster.get(j))==0)
- {
- x=j;
- break;
- }
- }
- if(x>=0)
- {
- if(locations.containsKey(tokens[2]+tokens[3]))
- {
- String loc=locations.get(tokens[2]+tokens[3]);
- pass.put(tokens[0],loc);
- TeamMap tm = new TeamMap(name,lat,lon,people,pass);
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement