You should take a parameter in Eat() function which will be the food as you are calling pets[0].Eat()... without an argument. In your switch case, pass string food in Eat() and then compare to favfood and then do the hungry functionality.