/** A band made up of three musicians. */
public class Band {
  
  /** The first musician in the band. */
  private Musician member1;
  
  /** The second musician in the band. */
  private Musician member2;
  
  /** The third musician in the band. */
  private Musician member3;
  
  /**
   * Create a new band with members m1, m2 and m3.
   */
  public Band(Musician m1, Musician m2, Musician m3) {
    this.member1 = m1;
    this.member1.joinedBand();
    this.member2 = m2;
    this.member2.joinedBand();
    this.member3 = m3;
    this.member3.joinedBand();
  }
  
 /**
   * Get member one of the band.
   */
  public Musician getMemberOne() {
    return this.member1;
  } 

  /**
   * Get the hourly salary total for the band.
   */
  public double getTotalSalary() {
    return this.member1.getSalary() 
      + this.member2.getSalary() 
      + this.member3.getSalary();
  }
  
  /**
   * Returns true if the band is within budget b.
   */
  public boolean isWithinBudget(double b) {
    return this.getTotalSalary() <= b;
  }
  
  /**
   * Returns true if Musicians m1 and m2 are the same.
   * 
   * - this is a "helper method", that's why it's private!
   */
  private boolean compare(Musician m1, Musician m2) {
    return m1.isEqual(m2);
  }
  
  /**
   * Returns true if this band is equal to band b1.
   * 
   * - exercise: figure out what the problem with this method is.
   */
  public boolean isEqual(Band b1) {
    return (this.compare(this.member1, b1.member1) 
      || this.compare(this.member1, b1.member2)
      || this.compare(this.member1, b1.member3))
      && (this.compare(this.member2, b1.member1) 
      || this.compare(this.member2, b1.member2)
      || this.compare(this.member2, b1.member3))
      && (this.compare(this.member3, b1.member1) 
      || this.compare(this.member3, b1.member2)
      || this.compare(this.member3, b1.member3));
  }
  
  /**
   * Returns the String representation of this band.
   */
  public String toString() {
    return "Member 1: " + this.member1.toString() + '\n'
      + "Member 2: " + this.member2.toString() + '\n'
      + "Member 3: " + this.member3.toString();
  }
    
    
}

