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


Python Car.decelerate方法代码示例

本文整理汇总了Python中car.Car.decelerate方法的典型用法代码示例。如果您正苦于以下问题:Python Car.decelerate方法的具体用法?Python Car.decelerate怎么用?Python Car.decelerate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在car.Car的用法示例。


在下文中一共展示了Car.decelerate方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_car_decelerate

# 需要导入模块: from car import Car [as 别名]
# 或者: from car.Car import decelerate [as 别名]
def test_car_decelerate():
    road = Road()
    car = Car(road)
    assert car.speed == 15
    car.decelerate()
    assert car.speed == 13
    car.speed = 1
    car.decelerate()
    assert car.speed == 0
开发者ID:jwaldrep,项目名称:traffic-simulation,代码行数:11,代码来源:test_car.py

示例2: test_car_neagtive_speed

# 需要导入模块: from car import Car [as 别名]
# 或者: from car.Car import decelerate [as 别名]
def test_car_neagtive_speed():
    my_car = Car()
    my_car.speed = 0
    my_car.decelerate()
    assert my_car.speed == 0
开发者ID:tshealy,项目名称:traffic-simulation,代码行数:7,代码来源:test_car.py

示例3: test_car_random_decelerate

# 需要导入模块: from car import Car [as 别名]
# 或者: from car.Car import decelerate [as 别名]
def test_car_random_decelerate():
    my_car = Car()
    my_car.speed = 30
    my_car.decelerate()
    assert my_car.speed == 28
开发者ID:tshealy,项目名称:traffic-simulation,代码行数:7,代码来源:test_car.py

示例4: test_car_can_not_go_negative

# 需要导入模块: from car import Car [as 别名]
# 或者: from car.Car import decelerate [as 别名]
def test_car_can_not_go_negative():
    car = Car()
    car.speed = 0
    car.decelerate()
    assert car.speed == 0
开发者ID:jdhiggins,项目名称:traffic-simulation,代码行数:7,代码来源:car_test.py

示例5: test_car_decelerates

# 需要导入模块: from car import Car [as 别名]
# 或者: from car.Car import decelerate [as 别名]
def test_car_decelerates():
    car = Car()
    car.speed = 30
    car.decelerate()
    assert car.speed == 28
开发者ID:jdhiggins,项目名称:traffic-simulation,代码行数:7,代码来源:car_test.py


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