Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.ArrayList;
- public class RecipeList {
- private ArrayList<Recipe> recipes;
- public RecipeList() {
- this.recipes = new ArrayList<>();
- }
- public void add(Recipe recipe) {
- this.recipes.add(recipe);
- }
- public void list() {
- System.out.println("Recipes: ");
- for (int i=0; i<this.recipes.size(); i++) {
- System.out.println(this.recipes.get(i).toString());
- }
- }
- public void findName(String name) {
- System.out.println();
- System.out.println("Recipes");
- for (int i=0; i<this.recipes.size(); i++) {
- if (this.recipes.get(i).getName().contains(name))
- System.out.println(this.recipes.get(i).toString());
- }
- System.out.println();
- }
- public void findCookingTime(int time) {
- System.out.println();
- System.out.println("Recipes");
- for (int i=0; i<this.recipes.size(); i++) {
- if (this.recipes.get(i).getCookingTime() <= time)
- System.out.println(this.recipes.get(i).toString());
- }
- }
- public void findIngredient(String name) {
- System.out.println();
- System.out.println("Recipes: ");
- for (int i=0; i<this.recipes.size(); i++) {
- if (this.recipes.get(i).containsIngredient(name))
- System.out.println(this.recipes.get(i).toString());
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement