Example #1
0
        static void Main(string[] args)
        {
            Car myCar = new Car();

            Car.myMethod();

            myCar.Make  = "Oldsmobile";
            myCar.Model = "Cutlas Supreme";
            myCar.Year  = 1986;
            myCar.Color = "silver";

            Car myOtherCar;

            myOtherCar = myCar;

            Console.WriteLine("{0} {1} {2} {3}", myOtherCar.Make, myOtherCar.Model, myOtherCar.Year, myOtherCar.Color);

            myOtherCar.Model = "98";
            Console.WriteLine("{0} {1} {2} {3}", myOtherCar.Make, myOtherCar.Model, myOtherCar.Year, myOtherCar.Color);

            myOtherCar = null;

            Car myThirdCar = new Car("ford", "Escape", 2005, "white");

            Console.ReadLine();
        }
Example #2
0
        static void Main(string[] args)
        {
            Car mycar = new Car();

            //Set properties

            Car myOtherCar = mycar;

            myOtherCar = null;
            mycar      = null;
            Car.myMethod();
        }
Example #3
0
        //calls static method for no reason
        //create myCar object, and peint out onto screen.
        //make otherCar object and set = to myCar. both have same refs now.
        //changing one changes the other.
        //setting one to null removes it but other stays.
        //create third car using overloaded constructor.


        static void Main(string[] args)
        {
            Car.myMethod(); //static method in the car class
            Car myCar = new Car();



            ///*
            myCar.Make  = "batmancar";
            myCar.Model = "BMW";
            myCar.Year  = 1993;
            myCar.Color = "Silver";
            //*/
            Car otherCar;

            otherCar = myCar;

            Console.WriteLine("{0} {1} {2} {3}",
                              otherCar.Make,
                              otherCar.Model,
                              otherCar.Year,
                              otherCar.Color);

            otherCar.Make = "supercar";

            Console.WriteLine("{0}", myCar.Make);
            Console.WriteLine("{0}", otherCar.Make);
            Console.WriteLine("{0}", otherCar.Year);

            myCar.Make = "oldone";
            Console.WriteLine("{0}", otherCar.Make);

            otherCar = null;

            /*
             * Console.WriteLine("{0} {1} {2} {3}",
             *  otherCar.Make,
             *  otherCar.Model,
             *  otherCar.Year,
             *  otherCar.Color);
             */

            myCar = null;
            //thrid car using overloaded constructor.
            Car thirdCar = new Car("makename", "modelname", 1993, "colorname");

            Console.ReadLine();
        }
Example #4
0
        static void Main(string[] args)
        {
            Car myCar = new Car();

            Car.myMethod();

            /*
             * myCar.Make = "Oldsmobile";
             * myCar.Model = "Cutlas Supreme";
             * myCar.Year = 1986;
             * myCar.Color = "Silver";
             *
             *
             * Car myThirdCar = new Car("Ford", "Escape", 2005, "White");
             *
             * Car myOtherCar = myCar;
             *
             *
             *
             * Console.WriteLine("{0} {1} {2} {3}",
             *  myOtherCar.Make,
             *  myOtherCar.Model,
             *  myOtherCar.Year,
             *  myOtherCar.Color);
             *
             * myOtherCar.Model = "98";
             *
             *
             * Console.WriteLine("{0} {1} {2} {3}",
             *  myCar.Make,
             *  myCar.Model,
             *  myCar.Year,
             *  myCar.Color);
             *
             * myOtherCar = null;
             *
             * /*
             * Console.WriteLine("{0} {1} {2} {3}",
             *  myOtherCar.Make,
             *  myOtherCar.Model,
             *  myOtherCar.Year,
             *  myOtherCar.Color);
             *
             * myCar = null;
             */

            Console.ReadLine();
        }
Example #5
0
        static void Main(string[] args)
        {
            //creating new instance of the Car class
            Car myCar = new Car();

            Console.WriteLine(myCar.Make);
            Console.ReadLine();

            //Overloaded constructer demo
            Car myThirdCar = new Car("Nissan", "Altima", 1999, "Grey");

            Console.WriteLine(myThirdCar.Model);
            Console.ReadLine();

            //static method demo
            Car.myMethod();

            //Static class Bicycle with a static method
            Bicycle.myBikeMessage();
        }
Example #6
0
        static void Main(string[] args)
        {
            Car myCar = new Car();

            Car.myMethod();
        }