本文整理汇总了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);
}
}
示例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));
}
示例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));
}
示例4: Park
public Ticket Park(Car car)
{
if (!IsNotFull()) throw new ParkinglotFullException();
var ticket = new Ticket();
carList.Add(ticket, car);
return ticket;
}
示例5: SetCarInfo
private bool SetCarInfo(Car car)
{
carNoStyle_label.Text = car.carStyle;
carNo_label.Text = car.carNo;
carFrameNo_label.Text = car.carFrameNo;
return true;
}
示例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();
}
示例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 };
}
示例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);
};
};
});
}
示例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);
}
示例10: Start
void Start()
{
car = GetComponent<Car>();
maxHealth = health;
damageParticles.maxParticles = 0;
damageParticles.Play();
}
示例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();
}
示例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);
}
示例13: Park
public string Park(Car value)
{
if (IsFull()) return null;
var parkingToken = ParkingToken.CreateParkingToken();
garage.Add(parkingToken, value);
return parkingToken;
}
示例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());
}
示例15: DeadReckoningStrategy
public DeadReckoningStrategy(Game game, Vector3 threshold)
{
this.Game = game;
this.threshold = threshold;
this.simulatedLocalCar = Car.CreateSimulatedCar(game);
game.Components.Add(simulatedLocalCar);
}