C# 基于c语言的汽车租赁程序设计#
我在租车项目上有工作,但我在租车课程上有一些问题。 如果我需要检查一下这辆车是否已经出租了?我该怎么办。 如果有这样的汽车库存声明数组:C# 基于c语言的汽车租赁程序设计#,c#,C#,我在租车项目上有工作,但我在租车课程上有一些问题。 如果我需要检查一下这辆车是否已经出租了?我该怎么办。 如果有这样的汽车库存声明数组: static void Main(string[] args) { Car[] car; car = new Car[5]; Car[] car; car = new Car[5]; car[0] = new Car("Number", "Brand", "Model",
static void Main(string[] args)
{
Car[] car;
car = new Car[5];
Car[] car;
car = new Car[5];
car[0] = new Car("Number", "Brand", "Model", Kilometers);
and go on till car[4]
我应该如何检查汽车?只需向您的
汽车类添加一个布尔值IsRent属性,每次有人租用汽车时,将其值更改为false。诸如此类的事:
if(car[/here put the index].IsRent==true)//car is not in rent,allow to rent.
{
car[/here put the index].IsRent=false;
//rent the car.
}
public bool IsRentM
{
get { return IsRent; }
set { IsRent = value; }
}
祝你好运。我应该在属性中使用什么get{…}和set{…}。@Isafe补充道。如果我帮了你,请记下我的答案:)非常感谢@Slashy如果可能“==true”这很有帮助吗?用面向对象的方式思考。当你说汽车是租来的或者汽车不是租来的。这是一种“是”的关系。现在您应该了解“is a”和“has a”的关系。要在一个Car对象的属性更改后更新ui,您需要实现INotifyPropertyChanged接口