Field ‘Mazlicek.hunger’ is never assigned to, and will always have its default value 0

Hello, I really need help. I'm getting these warnings:

  • Field 'Mazlicek.hunger' is never assigned to, and will always have its default value 0
  • Field 'Mazlicek.boredom' is never assigned to, and will always have its default value 0

and these errors:

  • There is no argument given that corresponds to the required formal parameter 'hunger' of 'Mazlicek.SetHunger(int)'
  • There is no argument given that corresponds to the required formal parameter 'boredom' of 'Mazlicek.SetBoredom(int)'

my code: Mazlicek.cs:

using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Threading; namespace TamagotchiConsole { class Mazlicek { private int hunger; private int boredom; private string mood; private bool isLiving; private void Moods() { if ((boredom + hunger) > 15) { mood = "angry"; } else if ((boredom + hunger) > 10 && (boredom + hunger) < 15) { mood = "frustrated"; } else if ((boredom + hunger) > 5 && (boredom + hunger) < 11) { mood = "fine"; } else { mood = "happy"; } } public void SetHunger(int hunger) { this.hunger = hunger; } public int GetHunger() { return hunger; } public void SetBoredom(int boredom) { this.boredom = boredom; } public int GetBoredom() { return boredom; } public string GetMood() { return mood; } public bool GetIsLiving() { return isLiving; } private void MoodCount() { while ((boredom + hunger) < 45) { Task.Delay(20000); hunger += 1; boredom += 1; } isLiving = false; } } } 

Program.cs:

using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Timers; namespace TamagotchiConsole { class Program { static void Main(string[] args) { Console.WriteLine("0 - close"); Mazlicek neakyPet = new Mazlicek(); while (neakyPet.GetIsLiving() == true) { int input = Convert.ToInt32(Console.ReadLine()); if (input == 0) { Environment.Exit(0); } else if (input == 1) { Console.WriteLine("Your pet is " + neakyPet.GetMood()); } else if (input == 2) { Console.WriteLine("Feeding.."); neakyPet.SetHunger() = neakyPet.GetHunger() - 10; } else if (input == 3) { Console.WriteLine("Playing.."); neakyPet.SetBoredom() = neakyPet.GetBoredom() - 10; } else { Console.WriteLine("Invalid number."); } } Console.WriteLine("Your pet died.."); Console.ReadLine(); } } } 

I'm using Visual Studio 2015, and everything is in one project. the code should do:

  • when I press 0, it exits the program.
  • when I press 1, it writes down the mood of the pet.
  • when I press 2, it feeds the pet –> hunger – 10.
  • when I press 3, it will play with the pet –> boredom – 10.
  • every twenty seconds hunger and boredom will raise.

Please help! I really need it ASAP (it's an homework)! Thanks in advance 🙂

Sorry for my English, I'm not native speaker.

by Cakepufft via /r/csharp

Leave a Reply