示例#1
0
        ///////////////////////////////////////
        // CLASSES - see definitions at end of file
        ///////////////////////////////////////
        public static void Classes()
        {
            // See Declaration of objects at end of file

            // Use new to instantiate a class
            Bicycle trek = new Bicycle();

            // Call object methods
            trek.SpeedUp(3); // You should always use setter and getter methods
            trek.Cadence = 100;

            // ToString is a convention to display the value of this Object.
            Console.WriteLine("trek info: " + trek.Info());

            // Instantiate a new Penny Farthing
            PennyFarthing funbike = new PennyFarthing(1, 10);

            Console.WriteLine("funbike info: " + funbike.Info());

            Console.Read();
        } // End main method
示例#2
0
        ///////////////////////////////////////
        // CLASSES - Veja definições no fim do arquivo
        ///////////////////////////////////////
        public static void Classes()
        {
            // Veja Declaração de objetos no fim do arquivo

            // Use new para instanciar uma classe
            Bicycle trek = new Bicycle();

            // Chame métodos do objeto
            trek.SpeedUp(3); // Você deve sempre usar métodos setter e getter
            trek.Cadence = 100;

            // ToString é uma convenção para exibir o valor desse Objeto.
            Console.WriteLine("trek info: " + trek.Info());

            // Instancie um novo Penny Farthing
            PennyFarthing funbike = new PennyFarthing(1, 10);

            Console.WriteLine("funbike info: " + funbike.Info());

            Console.Read();
        } // Fim do método principal