Exemple #1
0
        // constructor
        public Personen(string naam, DateTime gebortedatum, string naamHuisdier, string soortHuisdier) // ctor + tab shortcut
        {
            this.naam         = naam;
            this.gebortedatum = gebortedatum;

            Huisdieren h = new Huisdieren(naamHuisdier, soortHuisdier); // out of the parameters as a new object, but in the parameters in the e.g. below

            this.huisdier = h;
        }
Exemple #2
0
        static void Main(string[] args)
        {
            // the connection 1-1 and 1-*  via the coding in C#

            // 1-1 relation is based on the adding one reliable class as an object or as a parameter to the main object
            // Persoon 1 = using the constractor with a pat directly from parameters

            Personen persoon1 = new Personen("Carl Orph", new DateTime(1895, 07, 10), "Cher Ami", "Duif");



            // Persoon 2 using the constractor with a pat as an object
            Huisdieren h        = new Huisdieren("Spotty", "Hond");
            Personen   persoon2 = new Personen("A Gitlee", new DateTime(1889, 4, 20), h);

            // INFO

            persoon1.Info();
            Console.WriteLine("--------------------------");
            persoon2.Info();

            // getters and setters
        }
Exemple #3
0
 //overload of a class constructor the same as an overloading of methods = to add the class with the same name but additional paraneters
 public Personen(string naam, DateTime gebortedatum, Huisdieren h) // ctor + tab shortcut
 {
     this.naam         = naam;
     this.gebortedatum = gebortedatum;
     this.huisdier     = h;
 }