public class Topping {

 private String name;
 private double myprice;
 
 private static final String[] legalToppings = 
  	{"Cheese", "Mushrooms", "Bacon", 
  	"Pickles", "Tomatoes"};
 private static final double[] prices = 
 	{0.2, 0.3, 0.4, 0.1, 0.15};

 
 /* Constructor: public, has no return value, and
  * has the same name as the class
  */
 public Topping(String s) {
  	name = s;
  	for(int i = 0; i < legalToppings.length; i++) {
   		if(legalToppings[i].equals(name)) {
    		myprice = prices[i];
    		break;
   		}
  	}
 }
  
 /* Return the price of the topping */
 public double getPrice() {
  	return myprice;
 }
 
 /* Return the name of the topping */
 public String getName() {
  	return name;
 }

 /* Return the string representation of this Topping
  */
 public String toString() {
  	return name + " " + myprice;
 }
 
 /* Two toppings are the equal if they have the
  * same name and the same price
  */
 public boolean equals(Topping t) {
  	return (t.getName().equals(name) && 
  		    (t.getPrice() == myprice));
 }
}
