当前位置: 首页>>代码示例>>C#>>正文


C# Car类代码示例

本文整理汇总了C#中Car的典型用法代码示例。如果您正苦于以下问题:C# Car类的具体用法?C# Car怎么用?C# Car使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Car类属于命名空间,在下文中一共展示了Car类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Main

        static void Main()
        {
            var bag = new PriorityQueue<Car>();

            var opel = new Car
            {
                Model = "Opel",
                Price = 1000
            };
            var mercedes = new Car
            {
                Model = "Mercedes",
                Price = 5000
            };

            var citroen = new Car
            {
                Model = "Citroen",
                Price = 3000
            };

            bag.Enqueue(opel);
            bag.Enqueue(mercedes);
            bag.Enqueue(citroen);

            while(bag.Count > 0)
            {
                var car = bag.Dequeue();
                Console.WriteLine("{0} -> {1}",car.Model, car.Price);
            }
        }
开发者ID:radkomitev,项目名称:Telerik-Academy,代码行数:31,代码来源:StartUp.cs

示例2: should_be_able_to_pick_car

 public void should_be_able_to_pick_car()
 {
     smartParkingBoy.Manage(new ParkingLot());
     var car = new Car();
     var token = smartParkingBoy.Park(car);
     Assert.Same(car, smartParkingBoy.Pick(token));
 }
开发者ID:chenbojian,项目名称:OO,代码行数:7,代码来源:SmartParkingBoyFact.cs

示例3: Main

        static void Main(string[] args)
        {
            //Printing  -  Genreic List Version Atribute  - Problem.04
            var result = typeof(GenericList<int>).GetCustomAttributes(true).First();
            Console.WriteLine(result);

            GenericList<Car> cars = new GenericList<Car>();

            Car ferrari = new Car("Ferrari", "F360", 155000);
            cars.Add(ferrari);
            Car alfa = new Car("Alfa", "Spider", 95000);
            cars.Add(alfa);
            Car mercedes = new Car("Mercedes", "AMG SL65", 135000);
            cars.Add(mercedes);
            Car lada=new Car("Lada","1500",2500);

            Console.WriteLine(cars[0]);
            Console.WriteLine(cars[1]);
            Console.WriteLine(cars[2]);
            Console.WriteLine("List size {0}",cars.Size);
            Console.WriteLine("List capacity {0}",cars.Capacity);

            cars.InsertAt(lada, 2);
            Console.WriteLine(cars[2]);
            Console.WriteLine("List size {0}", cars.Size);
            Console.WriteLine(cars.Contains(ferrari));
        }
开发者ID:AdrianDamyanov,项目名称:CSharpOOP,代码行数:27,代码来源:MainClass.cs

示例4: Park

 public Ticket Park(Car car)
 {
     if (!IsNotFull()) throw new ParkinglotFullException();
     var ticket = new Ticket();
     carList.Add(ticket, car);
     return ticket;
 }
开发者ID:Jennifer-fu,项目名称:Parkinglot,代码行数:7,代码来源:Parkinglot.cs

示例5: SetCarInfo

 private bool SetCarInfo(Car car)
 {
     carNoStyle_label.Text = car.carStyle;
     carNo_label.Text = car.carNo;
     carFrameNo_label.Text = car.carFrameNo;
     return true;
 }
开发者ID:kooyou,项目名称:TrafficFinesSystem,代码行数:7,代码来源:CarFinesWeb.aspx.cs

示例6: PrepareData

		public void PrepareData()
		{
			ISession s = OpenSession();
			ITransaction txn = s.BeginTransaction();

			Car car = new Car();
			car.Id = GetNewId();
			car.Vin="123c";
			car.Owner="Kirsten";
			s.Save(car);

			Truck truck = new Truck();
			truck.Id = GetNewId();
			truck.Vin = "123t";
			truck.Owner="Steve";
			s.Save(truck);

			SUV suv = new SUV();
			suv.Id = GetNewId();
			suv.Vin = "123s";
			suv.Owner="Joe";
			s.Save(suv);

			Pickup pickup = new Pickup();
			pickup.Id = GetNewId();
			pickup.Vin = "123p";
			pickup.Owner="Cecelia";
			s.Save(pickup);

			txn.Commit();
			s.Close();
		}
开发者ID:marchlud,项目名称:nhibernate-core,代码行数:32,代码来源:NativeSQLBulkOperations.cs

示例7: SetUp

        public void SetUp()
        {
            _game = new Game();

            _gameObject =
                Object.Instantiate(Resources.LoadAssetAtPath("Assets/CarRed.prefab", typeof(GameObject))) as GameObject;
            if (_gameObject == null) return;
            _autoBehaviour = _gameObject.AddComponent<CarBehaviour>();
            _car = new Car(_autoBehaviour);

            _gameObjectOther =
                Object.Instantiate(Resources.LoadAssetAtPath("Assets/CarBlue.prefab", typeof(GameObject))) as GameObject;
            if (_gameObjectOther == null) return;
            _gameObjectOther.AddComponent<CarBehaviour>();
            _carOther = new Car(_gameObjectOther.GetComponent<CarBehaviour>());

            List<Car> cars = new List<Car>();
            for (int i = 0; i < GameData.CARS_AMOUNT; i++)
            {
                Car c = new Car(_autoBehaviour);
                cars.Add(c);
            }
            MainScript.Cars = cars;
            MainScript.SelfCar = new Car { CarObject = _autoBehaviour };
        }
开发者ID:KvanNes,项目名称:Contextproject-Group5,代码行数:25,代码来源:Game_Test.cs

示例8: describe_compression_ratio

    void describe_compression_ratio()
    {
        Car car = null;

        new Tuples<int, int, double>
        {
            { 7, 87, .28 },
            { 8, 92, .30 },
            { 9, 96, .32 }
        }.Do(
        (compressionRatio, octane, effeciency) =>
        {
            context["car has compression ratio of {0} to 1".With(compressionRatio)] = () =>
            {
                before = () => car = new Car(compressionRatio);

                it["should have octane requirement of {0}".With(octane)] = () =>
                {
                    car.OctaneRequirement.should_be(octane);
                };

                it["should have brake thermal efficiency of {0}%".With(effeciency * 100)] = () =>
                {
                    car.BrakeThermalEffeciency.should_be(effeciency);
                };
            };
        });
    }
开发者ID:DevlinLiles,项目名称:NSpec,代码行数:28,代码来源:describe_car.cs

示例9: Main

  public static void Main()
  {
    // Car porsche = new Car("2014 Porsche 911", 114991, 7864);
    // Car ford = new Car("2011 Ford F450", 55995, 14241);
    // Car lexus = new Car("2013 Lexus RX 350", 44700, 20000);
    // Car mercedes = new Car("Mercedes Benz CLS550", 39900, 37979);
    // Car jalopy = new Car("Uncle Beater's Ride", 500, 250000, "Beater");

    Car newCar = new Car();
    newCar.SetMakeModel("Chevy Crossover");
    newCar.SetMiles(83000);
    newCar.SetPrice(15000);
    newCar.SetCondition("Good");
    Console.WriteLine(newCar.GetMakeModel());
    Console.WriteLine("Miles: " + newCar.GetMiles());
    Console.WriteLine("Price: $" + newCar.GetPrice());
    Console.WriteLine("Condition: " + newCar.GetCondition());
    Console.WriteLine(newCar.GetMakeModel() + " is in " + newCar.GetCondition() + " condition.");




    // Console.WriteLine("Enter maximum price: ");
    // string stringMaxPrice = Console.ReadLine();
    // int maxPrice = int.Parse(stringMaxPrice);
    //
    // Console.WriteLine("Enter maximum miles: ");
    // string stringMaxMiles = Console.ReadLine();
    // int maxMiles = int.Parse(stringMaxMiles);


  }
开发者ID:cbkinor,项目名称:cars,代码行数:32,代码来源:Car.cs

示例10: Start

 void Start()
 {
     car = GetComponent<Car>();
     maxHealth = health;
     damageParticles.maxParticles = 0;
     damageParticles.Play();
 }
开发者ID:marrony,项目名称:ncar,代码行数:7,代码来源:CarDamage.cs

示例11: Main

        static void Main(string[]args)
        {
            var car = new Car() {
                Manufacturer = "Mercedes-Benz",
                Model = "New A Class",
                Colour = "Gray"
            };

            var carRepository = new MongoDbRepository<Car>();

            Console.WriteLine("Inserting car");
            var insertResult = carRepository.Insert(car);

            Console.WriteLine("Updating car");
            car.Colour = "Blue";
            var updateResult = carRepository.Update(car);

            Console.WriteLine("Search cars");
            var searchResult = carRepository.SearchFor(c => c.Colour == "Blue");

            Console.WriteLine("Get all cars");
            var getAllResult = carRepository.GetAll();

            Console.WriteLine("Getting car by id");
            var getByIdResult = carRepository.GetById(car.Id);

            Console.WriteLine("Deleting car");
            var deleteResult = carRepository.Delete(car);

            Console.Write("Press any key to continue...");
            Console.ReadKey();
        }
开发者ID:huoxudong125,项目名称:MongoDbRepository,代码行数:32,代码来源:Program.cs

示例12: Garage

 public Garage()
 {
     carArray[0] = new Car("Rusty", 30);
     carArray[1] = new Car("Clunker", 55);
     carArray[2] = new Car("Zippy", 30);
     carArray[3] = new Car("Fred", 30);
 }
开发者ID:walrus7521,项目名称:code,代码行数:7,代码来源:Enum.cs

示例13: Park

 public string Park(Car value)
 {
     if (IsFull()) return null;
     var parkingToken = ParkingToken.CreateParkingToken();
     garage.Add(parkingToken, value);
     return parkingToken;
 }
开发者ID:QMXGITHUB,项目名称:OOParkingSlot,代码行数:7,代码来源:Parkinglot.cs

示例14: DeleteCar

 public void DeleteCar(Car car)
 {
     FileDatabase fileDatabase = new FileDatabase("data");
     int i = _cars.FindIndex(x => car == x);
     _cars.RemoveAt(i);
     fileDatabase.SaveToDatabase(_cars.ToArray());
 }
开发者ID:ndiezel0,项目名称:Lesson2,代码行数:7,代码来源:AdminForCars.cs

示例15: DeadReckoningStrategy

 public DeadReckoningStrategy(Game game, Vector3 threshold)
 {
     this.Game = game;
     this.threshold = threshold;
     this.simulatedLocalCar = Car.CreateSimulatedCar(game);
     game.Components.Add(simulatedLocalCar);
 }
开发者ID:MintL,项目名称:datx02-rally,代码行数:7,代码来源:DeadReckoningStrategy.cs


注:本文中的Car类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。