
It looks like you're new here. If you want to get involved, click one of these buttons!
What is the problem with this code?
using System;
namespace Beginner
{
class Wizard
{
public string name;
public string favoriteSpell;
public int spellSlots;
public float experience;
public void CastSpell()
{
if(spellSlots > 0)
{
Console.WriteLine(name + " casts " + favoriteSpell);
spellSlots--;
experience += 0.3f;
}
else
{
Console.WriteLine(name + "is out of spell slots.");
}
}
public void Meditate()
{
Console.WriteLine(nameof + " meditates to regain spell slots.");
spellSlots = 3;
}
}
class Program
{
public static void Main(string[] args)
{
Console.ForegroundColor = ConsoleColor.Green;
Console.WindowHeight = 50;
Console.WindowWidth = 70;
Wizard wizard01 = new Wizard();
wizard01.name = "Mateo Souto";
wizard01.favoriteSpell = "Avada Kadavra";
wizard01.spellSlots = 3;
wizard01.experience = 0f;
wizard01.CastSpell();
wizard01.CastSpell();
wizard01.CastSpell();
wizard01.CastSpell();
wizard01.Meditate();
wizard01.CastSpell();
wizard01.CastSpell();
wizard01.CastSpell();
wizard01.CastSpell();
Console.WriteLine("Experience: " + wizard01.experience);
Console.ReadKey();
}
}
}
Answers
Works now for some reason I don't understand, but the errors are still there.