コード例 #1
0
        public static void Main(string[] args)
        {
            //shows how to instantiate different engines.
            //since all vehicles and cars will need an engine,
            //it's better to instantiate engines firstly

            NormalEngine   normalengine   = new NormalEngine(0.25);
            ElectricEngine electricengine = new ElectricEngine(0.45);
            HybridEngine   hybridengine   = new HybridEngine(0.65, 0.55);          //hybrid engine have two properties
            MotorEngine    motorengine    = new MotorEngine(0.10);

            //shows how to instantiate different kinds of vehicles

            Car          mycar        = new Car("Toyota", "Rav4", 2008, "compact", "Red", "xxxx", "Qilu", normalengine);
            Bus          mybus        = new Bus(10, "Toyota", "Rav4", 2008, true, 55, "Red", "xxxx", "Qilu", normalengine);
            EmergencyCar emergencycar = new EmergencyCar(10, "Toyota", "Rav4", 2008, "hospital", "Red", "xxxx", "Qilu", normalengine);
            Truck        mytruck      = new Truck(8, "Toyota", "Rav4", 2008, 7000, "Red", "xxxx", "Qilu", hybridengine);
            MotorCycle   motor        = new MotorCycle("Toyota", "Rav4", 2008, "Red", "xxxx", "Qilu", motorengine);
            PoliceCar    policecar    = new PoliceCar("Ford", "Mustang", 2012, "SUV", "LAPD", "Black", "xxxxxxx", "Matt", hybridengine);
            SchoolBus    schoolbus    = new SchoolBus(10, "Toyota", "Rav4", 2008, false, 40, "Red", "xxxx", "Qilu", electricengine);
            PoliceMotor  policemotor  = new PoliceMotor("Toyota", "Rav4", 2008, "LAPD", "Red", "xxxx", "Qilu", motorengine);
        }
コード例 #2
0
		public static void Main (string[] args)
		{
			//shows how to instantiate different engines.
			//since all vehicles and cars will need an engine,
			//it's better to instantiate engines firstly

			NormalEngine normalengine = new NormalEngine (0.25);   
			ElectricEngine electricengine = new ElectricEngine (0.45);
			HybridEngine hybridengine = new HybridEngine (0.65,0.55);  //hybrid engine have two properties 
			MotorEngine motorengine = new MotorEngine (0.10);

			//shows how to instantiate different kinds of vehicles

			Car mycar = new Car ("Toyota", "Rav4", 2008, "compact", "Red", "xxxx", "Qilu",normalengine);
			Bus mybus = new Bus (10, "Toyota", "Rav4", 2008, true, 55, "Red", "xxxx", "Qilu", normalengine );
			EmergencyCar emergencycar = new EmergencyCar (10,"Toyota","Rav4",2008,"hospital","Red","xxxx","Qilu",normalengine);
			Truck mytruck = new Truck ( 8, "Toyota", "Rav4", 2008, 7000, "Red", "xxxx", "Qilu",hybridengine);
			MotorCycle motor = new MotorCycle ("Toyota", "Rav4", 2008, "Red", "xxxx", "Qilu",motorengine);
			PoliceCar policecar = new PoliceCar ("Ford", "Mustang", 2012, "SUV", "LAPD", "Black", "xxxxxxx", "Matt",hybridengine);
			SchoolBus schoolbus = new SchoolBus (10, "Toyota", "Rav4", 2008, false, 40, "Red", "xxxx", "Qilu" ,electricengine);
			PoliceMotor policemotor = new PoliceMotor ("Toyota", "Rav4", 2008, "LAPD", "Red", "xxxx", "Qilu",motorengine);

		}