what is wrong with the code i get
'Error 1 Inconsistent accessibility: parameter type
'ConsoleApplication1.Garage.CarDelegate' is less accessible than method
'ConsoleApplication1.Car.process(ConsoleApplicatio n1.Garage.CarDelegate)
' E:\VS2005_Study\Delegates.cs 49 23 ConsoleApplication1
'
using System;
using System.Collections.Generic;
using System.Text;
using System.Collections;
namespace ConsoleApplication1
{
public class Car
{
private String CName;
public bool rotateTires, washCar;
private int speed;
public String name {
get{return CName;}
set{CName=name;}
}
public Car(String name, int s,bool Tire, bool Wash)
{
CName = name;
rotateTires = Tire;
washCar = Wash;
speed = s;
}
public void accelerate(int delta)
{
if (speed > 100)
return;
speed += delta;
if (speed <= 80)
{
Garage.caution(CName + " Going");
}
else if (speed > 80 && speed < 100)
{
Garage.caution("hi " + CName + " take Caution");
}
else if (speed > 100)
{
Garage.expiry("Oh man " + CName + " is Dead");
}
}
public void process(Garage.CarDelegate c)
{
c(this);
}
}
class Garage
{
public delegate void cautionDelegate(String msg);
public delegate void expiryDelegate(String msg);
public delegate void CarDelegate(Car c);
public static cautionDelegate caution;
public static expiryDelegate expiry;
public static CarDelegate card;
public static void Main() {
System.Collections.ArrayList a = new
System.Collections.ArrayList();
caution = new Garage.cautionDelegate(cautionfunction);
expiry = new Garage.expiryDelegate(cautionfunction);
a.Add(new Car("0",10, true, true));
a.Add(new Car("1", 20,true, false ));
a.Add(new Car("2", 30,false , true));
a.Add( new Car("3", 40,false , false ));
for (int i = 0; i < 5; i++)
{
foreach (Car c in a)
c.accelerate(20);
}
card = new CarDelegate(new ServiceCenter().rotatetires);
foreach(Car c in a)
c.process(card);
card = new Car.CarDelegate(new ServiceCenter().cleancar);
foreach(Car c in a)
c.process(card);
Console.ReadLine();
}
public static void cautionfunction(String msg)
{
Console.WriteLine(msg);
}
}
class ServiceCenter
{
public void rotatetires(Car c)
{
if (c.rotateTires == true)
{
Console.WriteLine("Roted Car " + c.name);
}
}
public void cleancar(Car c)
{
if (c.washCar == true)
{
Console.WriteLine("Cleaned Car" + c.name);
}
}
}
}
*** Sent via Developersdex
http://www.developersdex.com ***