Skip to content

3 classes how it should be configure

Magda Sztorc

Magda Sztorc

Asked Oct 14, 2008, 5:06 AM EDT2 answers
Share
LinkedInX
Hello,

I created 3 classes: Person, Telephon, Card

the Cart class contain Person class and person class contain Telephon class.

My question is if it's correct or mabye the class telephon should be include directly in Card class? What is the better solution?

    public class Person
 {
        private string firstName;
        private string lastName;

        private Telephon telephonNumber= new Telephon();

        public string FirstName
        {
            get { return firstName; }
            set { firstName = value; }
        }

        public string LastName
        {
            get { return lastName; }
            set { lastName= value; }
        }

        public void setTelephon(string telephon)
        {
            telephonNumber.TelephonNumber = telephon;
       }

    public class Card
    {
       
        private Person osob = new Person ();

        public void AddPerson(string firstName, string secondName, string telephon){

            osob.FirstName= firstName;
            osob.SecondName= secondName;
            osob.setTelephon = telephon;
        }

    public class Telephon
    {
        public int numer;

        public string nrTelefonu
        {
            get{ return numer; }
            set{ numer= value; }
        }

2 Answers

Know the answer? Post it. Somebody with the same question will find it here.

  • +1
    Hi! Well, You can leave your classes all outside themselfs. But still it would be good to make your code look little bit diffrentlly. For example: public class Telephon { public string nrTelefonu { get; set; } } public class Person { private Telephon telephonNumber= new Telephon(); public string FirstName { get; set;} public string LastName { get; set;} public void setTelephon(string telephon) { telephonNumber.nrTelefonu = telephon; } } public class Card { private Person osob = new Person(); public void AddPerson(string firstName, string secondName, string telephon) { osob.FirstName = firstName; osob.LastName = secondName; osob.setTelephon(telephon); } }
    +1
  • +1
    Sorry for my last post :)
    I'm strugling with this interface
    +1