package es.bhavishchandnani.myrestaurant.model;


import java.util.LinkedList;
import java.util.List;

public class Dishes {

    private List<Dish> dishes;

    public Dishes(List<Dish> dishes) {
        this.dishes = dishes;
    }

    public List<Dish> getDishes() {
        return dishes;
    }

    public void setDishes(List<Dish> dishes) {
        this.dishes = dishes;
    }

    public Dish getDish(int position){
        return dishes.get(position);
    }

    public List<Dish> getDishesWithType(DishType type){
        List<Dish> filteredDishes = new LinkedList<>();
        for (Dish dish : dishes) {
            if (dish.getType().equals(type)){
                filteredDishes.add(dish);
            }
        }
        return filteredDishes;
    }

    public int getCount() {
        return dishes.size();
    }
}

@@ -119,16 +119,52 @@
 shes %7B%0A%0A
+    private static Dishes instance;%0A
     priv
@@ -196,21 +196,22 @@
    p
-ublic
+rivate
  Dishes(
 List
@@ -210,57 +210,155 @@
 hes(
-List%3CDish%3E dishes) %7B%0A        this.dishes = dishes
+)%7B%7D%0A%0A    public static Dishes getInstance() %7B%0A        if (instance == null)%7B%0A            instance = new Dishes();%0A        %7D%0A        return instance
 ;%0A  

Modified Dishes Class converted to singleton