Exemplo n.º 1
0
        public static void Start()
        {
            Console.WriteLine("Starting...");
            //objects below
            Guitar gibson = new Guitar(Brand.Gibson, 10);
            //Guitar fender = new Guitar("Fender", 100);

            Musician kevin  = new Musician("Kevin", new Guitar(Brand.Fender, 1000)); //"gibson" is the value of the Guitar class instanstance which is a data type accepted into Musicians class
            Musician pontus = new Musician("Pontus", new Guitar(Brand.Gibson, 100));

            kevin.Play();
            pontus.Play();

            Console.WriteLine(kevin.Guitar.Price); //objectName.className.propertyName
        }
Exemplo n.º 2
0
 //constructor
 public Musician(string name, Guitar guitar) //Guitar --> full Guitar object
 {
     Name   = name;
     Guitar = guitar;
 }