What to change in this program so it produces a good output?
<p>The following code was taken from the book I'm studying and they say that the last half of the output should be in upper case, thanks to OnCarEngineEvent2. However when i compiled the program it wasn't the case. Why it doesn't work and what is needed to be changed? Thanks.</p>

<pre><code>public class Car
{
// Internal state data.
public int CurrentSpeed { get; set; }
public int MaxSpeed { get; set; }
public string PetName { get; set; }

// Is the car alive or dead?
private bool carIsDead;

// Class constructors.
public Car() { MaxSpeed = 100; }
public Car(string name, int maxSp, int currSp)
{
    CurrentSpeed = currSp;
    MaxSpeed = maxSp;
    PetName = name;
}


// 1) Define a delegate type.
public delegate void CarEngineHandler(string msgForCaller);

// 2) Define a member variable of this delegate.
private CarEngineHandler listOfHandlers;

// 3) Add registration function for the caller.
public void RegisterWithCarEngine(CarEngineHandler methodToCall)
{
    // listOfHandlers = methodToCall;
    // listOfHandlers += methodToCall; 
    // listOfHandlers += methodToCall; 
    if (listOfHandlers == null)
        listOfHandlers = methodToCall;
    else
        Delegate.Combine(listOfHandlers, methodToCall);
}


// 4) Implement the Accelerate() method to invoke the delegate’s 
//    invocation list under the correct circumstances.
public void Accelerate(int delta)
{
    // If this car is 'dead', send dead message.
    if (carIsDead)
    {
        if (listOfHandlers != null)
            listOfHandlers("Sorry, this car is dead...");
    }
    else
    {
        CurrentSpeed += delta;

        // Is this car 'almost dead'?
        if (10 == (MaxSpeed - CurrentSpeed)
            &amp;&amp; listOfHandlers != null)
        {
            listOfHandlers("Careful buddy!  Gonna blow!");
        }

        if (CurrentSpeed &gt;= MaxSpeed)
            carIsDead = true;
        else
            Console.WriteLine("CurrentSpeed = {0}", CurrentSpeed);
    }
}

}


class Program
{
    static void Main( string[] args )
    {
        Console.WriteLine("***** Delegates as event enablers *****\n");

        // First, make a Car object.
        Car c1 = new Car("SlugBug", 100, 10);
        c1.RegisterWithCarEngine(new Car.CarEngineHandler(OnCarEngineEvent));

        // This time, hold onto the delegate object,
        // so we can unregister later. 
        Car.CarEngineHandler handler2 = new Car.CarEngineHandler(OnCarEngineEvent2);
        c1.RegisterWithCarEngine(handler2);

        // Speed up (this will trigger the events).
        Console.WriteLine("***** Speeding up *****");
        for (int i = 0; i &lt; 6; i++)
            c1.Accelerate(20);

        // We won't see the 'uppercase' message anymore!
        Console.WriteLine("***** Speeding up *****");
        for (int i = 0; i &lt; 6; i++)
            c1.Accelerate(20);

        Console.ReadLine();
    }

    #region Delegate targets
    // We now have TWO methods that will be called by the Car
    // when sending notifications. 
    public static void OnCarEngineEvent( string msg )
    {
        Console.WriteLine("\n***** Message From Car Object *****");
        Console.WriteLine("=&gt; {0}", msg);
        Console.WriteLine("***********************************\n");
    }

    public static void OnCarEngineEvent2( string msg )
    {
        Console.WriteLine("=&gt; {0}", msg.ToUpper());
    }
    #endregion
}
</code></pre>
