Untitled
unknown
java
a month ago
1.2 kB
3
Indexable
Never
public class ChickenBurger { public String bun="Sesame"; public int price=200; public String sauceOption="Less"; public String spiceLevel="Not Set"; public String [] availableSpiceLevels={ "Mild, Spicy, Naga, Extreme" }; public String serveBurger(){ if ( spiceLevel.equals("Not Set")){ return "Cannot serve now. Customize Spice Level first."; } else{ return "The burger is being served:-\n" + "Bun Type: " + bun + "\n"+"Price: "+price+"\n"+"Sauce Option: "+sauceOption+"\n"+"Spice Level: "+spiceLevel; } } public void customizeSpiceLevel( String sLevel){ boolean savailable=false; for ( int i=0; i<availableSpiceLevels.length; i++ ){ if ( availableSpiceLevels[i].equals(sLevel)){ this.spiceLevel= sLevel; System.out.println("Spice level set to "+this.spiceLevel); savailable=true; break; } } if (!savailable){ System.out.println("This spice level is unavailable."); } }}
Leave a Comment