当前位置: 首页> 毕业设计 python-Data Type> Python的半开放式命题,更详细的instruction可加我qq联系,可议价

Python的半开放式命题,更详细的instruction可加我qq联系,可议价

* 若价格不公道,可以让提问者在平台追加赏金哦,平台是您利益的保证
已完成
Python的半开放式命题,更详细的instruction可加我qq联系,可议价 134****3077
赏 80元 收藏

问题详情:

It contains two classes: Package and Truck. You are to finish defining the Truck class.
Package
The Package class has only one method, the constructor. Each package is initialized with a unique identifier id and has four attributes:
• id (a string with only numeric characters) for the package’s unique identifier.
• address (a string) for the address to which the package is supposed to be delivered.
• office (a string) for the address of a post service office: if a package is not collected, then the attribute refers to the office where the package is; otherwise, it refers to from which office the package is collected.
• ownerName (a string) for the name to which the package is supposed to be delivered, and
• delivered (a Boolean) for indicating if the package is delivered or not.
• collected (a Boolean) for indicating if the package is collected by a truck or not.
You are free to define accessors and mutators, or you may change the attributes directly. The Package class will not be graded.
Truck
The template contains its basic attributes and methods. You are free to add more.
In the template, a truck has three attributes:
• id (a string with only numeric characters): the unique identifier of a truck.
• size (a non-negative integer): the size of the truck, i.e., the maximum number of packages can be stored in a truck (assuming all packages are of the same volume).
• location (a string): the current location of a truck.
• packages: the packages that have been loaded in a truck.
You get to decide the type of the packages attribute. It can be a Python list or any of the data structures we have covered (or will cover) in this class.
The methods you need to define include the followings.
• __init__(self, id, n, loc):Eachtruckisinitializedwithauniqueidentifierid,asizenandalocation loc. No matter what type you choose for the collection of packages in a truck, it should be initalized to be empty.
• collectPackage(self, pk): collect a package pk (an instance of Package), i.e., add to pk to self.packages. The truck and pk must be at the same post service office for the truck to be able to collect the package.
• deliverOnePackage(self, pk): deliver one pckage pk.
The truck has to be at the address specified by pk.address to be able to deliver the package.
• deliverPackages(self): deliver all packages that are supposed to be delivered to truck’s current location.
• removePackage(self, pk): remove a package pk from the truck and put it back to a post service office without delivering it. The truck must be at a post-service office for this to work and the removed package will be at the post-service office afterwards.
• driveTo(self, loc): drive from current location to location loc.
• getPackagesIds(self): return a Python list of the ids of the packages in self.packages. This is for
testing. The order of the ids does not matter.
Note
• Do not change the names of the attributes and methods in either class.
• Feel free to add more methods and attributes if needed.
• This part demonstrates the usage of at least one of the linear data structures we have learned in this class, including stack, queue, deque, linked list, and hash table.
* 若价格不公道,可以让提问者在平台追加赏金哦,平台是您利益的保证

分享会更快解决你的问题哦!

此处可发布评论

    暂无评论

    竞答该问题的人有:

    公告
    更多相关问题
    链表有关问题,包括合并、删除,求大神帮忙
    Python 网考 25号九点到十二点半 有往年考试题型
    急 大学入门级python表格类作业
    编写一个爬虫,并主动对比数据,和提醒
    模拟登陆,带验证码。手动输入验证码,验证码图片下载不下来
    python项目代码详解
    python的函数对象,是自己具有call属性,还是函数对象的类,或者父类具有call属性?
    执行python程序(多进程)的时候,看cpu发现系统占用CPU率很高,但是用户占用率很低
    为什么sklearn的LinearRegression要用形如x=[[6]]的列表来作为入参?

    第一时间了解动态

    关注我们