public class Pizza {
  
  /** The size of the pizza. */
  private String size;
    
  /** The toppings on the pizza. */
  private String[] toppings;
  
  /** The number of toppings currently on pizza.*/
  private int nbrToppings;
  /**
   * Create a new pizza.
   * @param s The size of the pizza.
   * @param numToppings The number of toppings
   * on the pizza.
   */
  public Pizza(String s, int numToppings) {
    this.size = s;
    toppings = new String[numToppings];
    nbrToppings = 0;
  }
  
  /** 
   * Add a topping to the pizza.  Return true
   * if topping was added, and false otherwise.
   */
  public boolean addTopping(String t) {
    if (this.nbrToppings < toppings.length) {
      toppings[nbrToppings] = t;
      nbrToppings++;
      return true;
    }
    return false;
  }
  
  /**
   * Remove a topping from the pizza.
   */
  public void removeTopping (String t) {
    for (int i = 0; i < nbrToppings; i++) {
      if (t.equals(toppings[i]) ){
        nbrToppings--;
        for (int j = i+1; j < nbrToppings; j++) {
          toppings[j-1] = toppings[j];
          toppings[j] = "";
        }
      }
    }
  }
  /** return pizza toppings as a string
   * */
  public String toString() {
  String result = "";
  for (int i = 0; i < nbrToppings; i++) {
    result += toppings[i] + " ";
  }
  return result;
    
  }
}
