Advertisement
apez1

Assignment 3: Ultimate Frisbee - UltimateTeam Class Submissi

Jan 23rd, 2019
496
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.17 KB | None | 0 0
  1. package ultimateFrisbee;
  2.  
  3. import java.util.ArrayList;
  4.  
  5.  
  6. public class UltimateTeam {
  7.    
  8.     private ArrayList<UltimatePlayer> players = new ArrayList<UltimatePlayer>();
  9.     private ArrayList<Coach> coaches = new ArrayList<Coach>();
  10.    
  11.    
  12.    
  13.     public UltimateTeam(ArrayList<UltimatePlayer> player, ArrayList <Coach> coach){
  14.        
  15.         this.players = player;
  16.         this.coaches = coach ;
  17.        
  18.     }
  19.    
  20.     public String getCutters() {
  21.        
  22.         String cutters = "";
  23.        
  24.         for(UltimatePlayer p: players) {
  25.            
  26.             if(p.getPosition().equals("cutter")) {
  27.                
  28.                 cutters += p;
  29.                 cutters += '\n' ;
  30.                
  31.             }
  32.            
  33.         }
  34.         return cutters ;
  35.                
  36.     }
  37.  
  38.     public String getHandlers() {
  39.        
  40.         String handlers = "";
  41.        
  42.         for(UltimatePlayer p1: players) {
  43.            
  44.             if(p1.getPosition().equals("handler")) {
  45.                 handlers += p1;
  46.                 handlers += '\n';
  47.             }
  48.            
  49.         }
  50.            
  51.        
  52.         return handlers ;
  53.     }
  54.    
  55.    
  56.     public String toString(){
  57.        
  58.         String output = "COACHES\n";
  59.          for(Coach c: coaches){
  60.            output += c;
  61.            output += "\n";
  62.          }
  63.          
  64.          output += "\nPLAYERS\n";
  65.          
  66.          for(UltimatePlayer pl: players){
  67.            output += pl;
  68.            output += "\n";
  69.          }
  70.           return output;
  71.          
  72.         }
  73.    
  74.    
  75. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement