views:

85

answers:

3

im trying to use this method to make my characters but i get the error: inconsistent accessibility:return type'consoleapplication1.Enemigo' is less accesible than method 'consoleapplication1.poringbuilder.makeporing()' its the first time i get this error and i really dont know what to do,i have tried alot of different ways but i get the same mistake plz help >.< namespace ConsoleApplication1 { public static class PoringBuilder { public static Enemigo MakePoring() { return new Enemigo(15, 0, 30,15, false, false,"Poring"); } }

this is another class namespace ConsoleApplication1 { class Enemigo:Personaje { public Enemigo(int Damage, int Defensa, int HP,int MP, bool Evade, bool Counter, string Nombre) : base(Damage, Defensa, HP,MP, Evade, Counter, Nombre) { } } }

this is the parent of all my classes namespace ConsoleApplication1 { class Personaje { public int Damage; public int Defensa;

    public int HP;

    public int MP;
    public bool Evade;
    public bool Counter;
    public string Nombre;
    //public Personaje() { }
    public Personaje(int Damage, int Defensa, int HP,int MP, bool Evade, bool Counter, string Nombre)
    {
        this.Damage = Damage;
        this.Defensa = Defensa;
        this.HP = HP;
        this.MP = MP;
        this.Evade = Evade;
        this.Counter = Counter;
        this.Nombre = Nombre;
    }
}

}

and im using it on the main program like this List EnemigosNoob = new List(); EnemigosNoob.Add(PoringBuilder.MakePoring());

i hope im precise enough >.<

A: 
public Poring() : this(/*your default values here*/) {}

Also, for your other constructor ... why are you overriding the values passed in?

Anon.
Well as i tried to say i will have about 10 characters and everyone of them will have different status but i think i got it thank you very much
Makenshi
A: 

Poring() is your default constructor. You need to declare it with, at least, a do-nothing body:

public Poring()
{
}

If desired, you can perform default initialisation in the body, though this is best handled by chaining to another constructor as per Anon's answer. In either case, though, you must have those two braces { } to form a body.

itowlson
A: 

Since you're not really adding anything to the Enemigo class, I would opt for a factory method sort of thing. Subclassing is normally for when you want to add behaviour to something.

public static class PoringBuilder
{
    public static Enemigo MakePoring()
    {
        return new Enemigo(30, 10, 0, false, false, 15, "Poring");
    }
}

And call it:

EnemigosNoob.Add(PoringBuilder.MakePoring());
Quick Joe Smith
WOW THATS WHAT I NEEDED THANK YOU VERY MUCH
Makenshi
What's with the shouting?
Anon.
He's clearly very excited.
Quick Joe Smith