Exemple #1
0
        static void Main(string[] args)
        {
            Automobile car = new Automobile();

            car.Start();
            Console.WriteLine($"The car is started: {car.IsOn}");
            car.Accelerate(20);
            Console.WriteLine();
            Console.WriteLine("It's an open stretch, gun it!");
            car.Accelerate(180);

            // See a cop
            car.Brake(60);
            Console.WriteLine();
            car.Brake();
        }
Exemple #2
0
    public static void Main()
    {
        // The output variable's type is `string` -- a built in type
        string output = "Nashville Software School";

        // The author variable's type is Writer -- a custom type you defined
        Writer author = new Writer("I do declare: ");

        author.Write(output);

        author.Prefix = "That's right, I said: ";
        author.Write(output);


        //For automobile example -- lecture code -- defined the class below, outside of Program Class
        Automobile generic_auto = new Automobile();

        Console.WriteLine($"Automobiles go {generic_auto.Accelerate()}");

        Car stella = new Car();

        Console.WriteLine($"Cars go {stella.Accelerate()}");
    }