Question Inheritance

Ruben

New member
Joined
Jan 26, 2013
Messages
2
Programming Experience
Beginner
Hello,

It's the 1st time that i'm programming in C # and have a class Shelfbooks derived from this class Shelves and i want to pass what is in this class Shelfbooks (books properties like name, title...) to the class Shelves.

class Shelfbooks : Shelves
    {
        Document[] shelf;

        private int val;

        public int Val
        {
            get { return val; }
            set { val = value; }
        }

        public Shelfbooks(int val)
        {
            shelf = new Document[val];
        }

        public void InsereBooks(Document L)
        {
            int cont = 0, i;
            for (i = 0; i < shelf.Length; i++)
            {
                if (shelf[i] == L)
                {
                    cont++;
                    break;
                }
                if (shelf[i] == null)
                    break;
            }
            if (cont == 0)
                shelf[i] = L;
        }
}


class Shelfves
    {
        string[] shelfves;

        public Shelves()
        {
        }

        public  Shelves(int val)
        {
            shelves = new string[val];
        }
}


Help please ...
Regards to all
 
Last edited by a moderator:

jmcilhinney

C# Forum Moderator
Staff member
Joined
Apr 23, 2011
Messages
3,141
Location
Sydney, Australia
Programming Experience
10+
What EXACTLY do these classes represent and what is their relationship? What exactly is the base class supposed to do with the data from the derived class? I think that it's safe to say that you should change your design but exactly how depends on exactly what you're trying to achieve.
 

Ruben

New member
Joined
Jan 26, 2013
Messages
2
Programming Experience
Beginner
Hello,

I managed to solve the problem, but thanks anyway...

Regards
 

newmember

New member
Joined
Jan 31, 2013
Messages
2
Programming Experience
3-5
Deriving "Book" class from "Shelves" Class is a bad design.
 
Top Bottom