怕黑的驼瑞驰在吐槽 level
获赞
0
粉丝
0
关注
0
看过 TA
3
嘉兴学院
2014
测试工程师
IP属地:浙江
暂未填写个人简介
私信
关注
2024-07-25 00:17
嘉兴学院 测试工程师
class Vehicle:def __init__(self, vehicle_type, vehicle_no):self.vehicle_type = vehicle_typeself.vehicle_no = vehicle_nodef start(self):print(f"您乘坐的是{self.vehicle_type},{self.vehicle_no}已启动")def stop(self):print(f"您乘坐的是{self.vehicle_type},{self.vehicle_no}已停止")class Taxi(Vehicle):def __init__(self, vehicle_type, vehicle_no, company):super().__init__(vehicle_type, vehicle_no)self.company = companydef start(self):print(f"乘客您好!\n我是{self.company}的,我的车牌号:{self.vehicle_no}, 请问您要去哪里?")def stop(self):print(f"目的地到了,请您付款下车,感谢您乘坐{self.vehicle_type},欢迎下次乘坐~")class Car(Vehicle):def __init__(self, vehicle_type, vehicle_no, owner):super().__init__(vehicle_type, vehicle_no)self.owner = ownerdef start(self):print(f"我是{self.owner},我的{self.vehicle_type}真好看!")def stop(self):print("目的地到啦,我们去玩儿吧!")class Bus(Vehicle):def __init__(self, vehicle_type, vehicle_no, stations):super().__init__(vehicle_type, vehicle_no)self.stations = stationsdef start(self):print(f"我是{self.vehicle_type},上有天堂下游苏杭~")def stop(self):print(f"前方到站{self.stations}")taxi = Taxi("杭州出租车", "浙A66666", "杭州xx集团")car = Car("劳斯莱斯幻影", "浙A8888", "阿波波")bus = Bus("杭州K155", "浙A15555", "立马回头")taxi.start()taxi.stop()print("*"*50)car.start()car.stop()print("*"*50)bus.start()bus.stop()
0 点赞 评论 收藏
分享

创作者周榜

更多
关注他的用户也关注了:
牛客网
牛客网在线编程
牛客网题解
牛客企业服务