Search code examples
c#classencapsulation

Weird Error with Encapsulated Nested Class


I have A Class Called "BaseMember"

I've made it abstact.

The reason for this is, I have two classes that extend BaseMember that are nested inside of BaseMember

The one I'm focusing on right now is JuniorMember.

My Environment doesn't recognise JuniorMember as being a class, even though I've already made the class.

but for some reason it recognises "BaseMember.JuniorMember"

BaseMember.JuniorMember jmem2 = new BaseMember.JuniorMember("Andrew", "Adderson", "Bjorn", "Sir", "Hillclose", "Sweden", "zr13ny", "[email protected]",
            564312, 01698763122, 3, "Junior", "AA1299J", 0, 0, "none", "Swift Swe's", "Male", 2, 99, 1, 2, "dkane", "santa", "999292", "", "yes");

I know this code isn't correct. I have another Nested Class structure like this which involves BaseRace which has Sprint and Run classes encapsulated inside it, and that works as intended:

https://i.sstatic.net/GtE6m.png

I have a few questions:

1) How do I fix my JuniorMember class so that I can use "JuniorMember" without having to write BaseMember.

2)this is kinda a bonus question -- I have like, 25 parameters, do I really need to do stuff like this every time I make a new extending class constructor? it's unsightly.

  public Sprint(string rname, int rid, string rloc, string rtime, string rdist, string rclimb, string rdesc, string rimg, string rter,
                string rcon, string rdir, string rwin, int rrecord, string rrace, string rdate,string rdatec,string rcat,string rgen, string rdif, string rlim, string rcre)
                : base(rname,rid,rloc,rtime,rdist,rclimb,rdesc,rimg,rter,rcon,rdir,rwin,rrecord,rrace,rdate,rdatec,rcat,rgen,rdif,rlim,rcre)
            {
            nameRace = rname;


    RaceID = rid;

    }

Thanks guys.

By the way, this is for a project to do with Members (Junior and Senior) only being able to join Junior and Senior Races. The Classes kinda have to be nested for this, I don't really see the benefit of them either, but I have to use them.


Solution

  • Rewrote the class myself and turns out all I had was a syntax error somewhere.

    works as intended now.