gpt-3.5-turbo-0613· openai
Suzhen/CodeChat
定义一个设备(IDevice)接口,该接口描述设备的启动(start),停止(stop),维修(maintain),工作(run)等功能。…
- User
定义一个设备(IDevice)接口,该接口描述设备的启动(start),停止(stop),维修(maintain),工作(run)等功能。 在接口之上,定义派生类-抽象类Device,该类包含设备编号,名称,使用者名字,使用日期等信息。 在抽象类Device上派生出手机类Mobile,实现启动,停止,维修,工作等功能。编写代码测试手机类的功能。
- Assistant
from abc import ABC, abstractmethod class IDevice(ABC): @abstractmethod def start(self): pass @abstractmethod def stop(self): pass @abstractmethod def maintain(self): pass @abstractmethod def run(self): pass class Device: def __init__(self, device_id, device_name, user_name, use_date): self.device_id = device_id self.device_name = device_name self.user_name = user_name self.use_date = use_date class Mobile(Device, IDevice): def __init__(self, device_id, device_name, user_name, use_date): super().__init__(device_id, device_name, user_name, use_date) def start(self): print("Mobile: Start") def stop(self): print("Mobile: Stop") def maintain(self): print("Mobile: Maintain") def run(self): print("Mobile: Run") # 测试手机类的功能 mobile = Mobile("123456", "iPhone", "John", "2021-01-01") mobile.start() mobile.stop() mobile.maintain() mobile.run()
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.