Advertisement
adityak2207

Recipe.java

Jan 28th, 2025 (edited)
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.80 KB | Source Code | 0 0
  1. import java.util.ArrayList;
  2.  
  3. public class Recipe {
  4.     private String name;
  5.     private int cookingTime;
  6.     private ArrayList<String> ingredients;
  7.  
  8.     public Recipe(String name, int cookingTime, ArrayList<String> ingredients) {
  9.         this.name = name;
  10.         this.cookingTime = cookingTime;
  11.         this.ingredients = ingredients;
  12.     }
  13.  
  14.     public String getName() {
  15.         return this.name;
  16.     }
  17.  
  18.     public int getCookingTime() {
  19.         return this.cookingTime;
  20.     }
  21.  
  22.     public boolean containsIngredient(String ingredient) {
  23.         if (this.ingredients.contains(ingredient))
  24.             return true;
  25.         else
  26.             return false;
  27.     }
  28.  
  29.     @Override
  30.     public String toString() {
  31.         return this.getName() + ", cooking time: " + this.getCookingTime();
  32.     }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement