I am working on a complicated computer science lab. I need to create a method called countItem which returns the quantity of a specified item. If the item is not in the list, it should return 0. Cart is an arraylist of Items. Getquantity returns the quantity which is a instance field of the item file.

After building I get two unexpected type errors. Can anyone help me fix this problem? I can post more code if needed. Thanks

EDIt: THE PROBLEM IS SOLVED THANKS SO MUCH!

```
public int countItem(Item purchase)
     {
        int purchase = 0;
        if(cart.indexOf(purchase) == -1) // error
            quantity = 0;
        else
            purchase.getQuantity() = quantity; //error

        return quantity;
      }

 public boolean removeItem(Item nameofitem)
     {

        boolean search;

        if(cart.indexOf(nameofitem) == -1)
            return search;
        else
            {
                cart.remove(cart.indexOf(nameofitem));
                search = true;
            }

        return search;
     }

```