ProfWendi

Teams Enumeration

Jun 4th, 2021
1,124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.46 KB | None | 0 0
  1. package ca.sheridancollege.jollymor.week4.repositories;
  2.  
  3. /**
  4.  * NHL Teams from the North Division (2020-2021), or all the Canadian
  5.  * teams during regular seasons (pre 2020-2021).
  6.  *
  7.  * @author Wendi Jollymore
  8.  *
  9.  */
  10. public enum Teams {
  11.     /** "Calgary", "Flames" */
  12.     CGY ("Calgary", "Flames"),
  13.     /** "Edmonton", "Oilers" */
  14.     EDM ("Edmonton", "Oilers"),
  15.     /** "Montreal", "Canadians" */
  16.     MTL ("Montreal", "Canadians"),
  17.     /** "Ottawa", "Senators" */
  18.     OTT ("Ottawa", "Senators"),
  19.     /** "Toronto", "Maple Leafs" */
  20.     TOR ("Toronto", "Maple Leafs"),
  21.     /** "Vancouver", "Canucks" */
  22.     VAN ("Vancouver", "Canucks"),
  23.     /** "Winnipeg", "Jets" */
  24.     WPG ("Winnipeg", "Jets");
  25.    
  26.     private String city;      // city team belongs to
  27.     private String teamName;  // name of the team
  28.     //private HashMap<String, String> mapCityToTeam;
  29.    
  30.     // standard enum constructor
  31.     private Teams(String city, String teamName) {
  32.         this.city = city;
  33.         this.teamName = teamName;
  34.     }
  35.    
  36.     /**
  37.      * Retrieves the city this team belongs to.
  38.      *
  39.      * @return this team's city
  40.      */
  41.     public String getCity() {
  42.         return city;
  43.     }
  44.    
  45.     /**
  46.      * Retrieves the team name.
  47.      *
  48.      * @return this team's name
  49.      */
  50.     public String getTeamName() {
  51.         return teamName;
  52.     }
  53.    
  54.     /**
  55.      * Retrieves this team as a String, which is just the city name
  56.      * followed by the team name.
  57.      *
  58.      * @return this team as a string
  59.      */
  60.     public String toString() {
  61.         return String.format("%s %s", city, teamName);
  62.     }
  63. }
Advertisement
Add Comment
Please, Sign In to add comment