Advertisement
Guest User

Untitled

a guest
Feb 18th, 2018
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.00 KB | None | 0 0
  1. PERSON :
  2.  
  3. //done
  4.  
  5. public class Person
  6. {
  7.   private String firstName = "";
  8.   private String lastName = "";
  9.  
  10.   public Person(String f, String l)
  11.   {
  12.     firstName = f;
  13.     lastName = l;
  14.   }
  15.  
  16.   public String toString()
  17.   {
  18.     return lastName +", "+ firstName;
  19.   }
  20. }
  21.  
  22.  
  23. CAPTAIN :
  24.  
  25. //done
  26.  
  27. public class Captain extends UltimatePlayer
  28. {
  29.   private boolean type;
  30.   private String offense;
  31.   private String defense;
  32.   private String side = "";
  33.  
  34.  
  35.   public Captain(String f, String l, String p, boolean t)
  36.   {
  37.     super(f, l, p);
  38.     type = t;
  39.   }
  40.  
  41.   public String toString()
  42.   {
  43.     if(type == true)
  44.     {
  45.       side= "offense";
  46.     }
  47.     else{
  48.       side= "defense";
  49.     }
  50.    
  51.     return super.toString() + "\n   Captain: "  + side;
  52.   }
  53. }
  54.  
  55.  
  56. COACH :
  57.  
  58. //done
  59.  
  60. public class Coach extends Person
  61. {
  62.   private String role = "";
  63.  
  64.  
  65.   public Coach(String f, String l, String r)
  66.   {
  67.     super(f, l);
  68.     role = r;
  69.    
  70.   }
  71.  
  72.   public String toString()
  73.   {
  74.     return super.toString() + "\n   Role: " + role;
  75.   }
  76. }
  77.  
  78. ULTIMATE PLAYER :
  79.  
  80. //done
  81.  
  82. public class UltimatePlayer extends Person
  83. {
  84.   private int jerseyNumber = 0;
  85.   private static int individual = 0;
  86.   private String handler;
  87.   private String cutter;
  88.  
  89.   private String position = "";
  90.  
  91.   public UltimatePlayer(String f, String l, String p)
  92.   {
  93.     super(f, l);
  94.    
  95.  
  96.     individual++;
  97.     jerseyNumber = individual;
  98.    
  99.     p = p.toLowerCase();
  100.     if( p.equals("handler") || p.equals("cutter"))
  101.     {
  102.       position = p;
  103.     }
  104.     else{
  105.       position = "handler";
  106.     }
  107.    
  108.   }
  109.  
  110.   public String getPosition()
  111.   {
  112.     return position;
  113.   }
  114.  
  115.   public String toString()
  116.   {
  117.     String temp = super.toString();
  118.     return temp + "\n   Jersey #: " + jerseyNumber + "\n   Position: " + position;
  119.   }
  120.    
  121. }
  122.  
  123.  
  124. ULTIMATE TEAM :
  125.  
  126. import java.util.ArrayList;
  127.  
  128. public class UltimateTeam
  129. {
  130.   private ArrayList<UltimatePlayer> players = new ArrayList <UltimatePlayer>();
  131.   private ArrayList<Coach> coaches = new ArrayList <Coach>();
  132.  
  133.  public UltimateTeam (ArrayList <UltimatePlayer> p, ArrayList <Coach> c)
  134.  {
  135.    players = p;
  136.    coaches = c;  
  137.  }
  138.  
  139.  public String getCutters()
  140.  {
  141.    String output = "";
  142.    for (UltimatePlayer p: players)
  143.    {
  144.      String pos = p.getPosition();
  145.      if(pos.equals("cutter")){
  146.        output += p.toString() + "\n";
  147. }
  148. }
  149.    return output;
  150.    
  151. }
  152.  public String getHandlers()
  153.  {
  154.    String output = "";
  155.    for(UltimatePlayer p: players)
  156.    {
  157.      String pos = p.getPosition();
  158.      if(pos.equals("handler"))
  159.      {
  160.        output += p.toString() + "\n";
  161.      }
  162.    }
  163.    return output;
  164.  }
  165.  
  166.  public String toString()
  167.  {
  168.    String output = "";
  169.     output += "COACHES\n";
  170.    for(Coach c: coaches)
  171.     {
  172.       output += c.toString() + "\n";
  173.     }
  174.     output += "\nPLAYERS\n";
  175.  
  176.    for(UltimatePlayer p: players)
  177.    {
  178.      output += p.toString() + "\n";
  179.    }
  180.  
  181.  
  182.  
  183.    
  184.  return output;
  185.  }
  186. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement