You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
class Car:
|
|
|
|
def __init__(self, license_plate, model, color):
|
|
|
|
|
|
|
|
self.license_plate = license_plate
|
|
|
|
self.model = model
|
|
|
|
self.color = color
|
|
|
|
|
|
|
|
def __str__(self):
|
|
|
|
"""返回车辆的字符串表示"""
|
|
|
|
return f"车牌号: {self.license_plate}, 车型: {self.model}, 颜色: {self.color}"
|
|
|
|
|
|
|
|
def update_info(self, license_plate=None, model=None, color=None):
|
|
|
|
|
|
|
|
if license_plate is not None:
|
|
|
|
self.license_plate = license_plate
|
|
|
|
if model is not None:
|
|
|
|
self.model = model
|
|
|
|
if color is not None:
|
|
|
|
self.color = color
|