Question
You are to finish the remaining classes for a truck delivery simulation. How the simulation works: Each truck will receive an itinerary list (list of
You are to finish the remaining classes for a truck delivery simulation.
How the simulation works:
Each truck will receive an itinerary list (list of depots) and will pick up and drop off cargo from listed depots. Each depot will have cargo that contains a destination depot. Each depot will place cargo onto a truck headed towards that destination, assuming that truck has room, if it does not, the cargo remains at the depot.
You do not need to output anything to the terminal, the test file will do that.
The only classes you need to modify are: Truck, Depot and Cargo.
Cargo:
Has a description
Has a destination
Can be held by a depot or truck (but not both!)
(Optional) can specify if the cargo has been delivered
Depot:
Has a name
Allows trucks to dock at the depot and offload packages
Will load cargo onto trucks that will be going to the cargo's destination.
Will hold a large number of cargo items (You do not need to impose a limit)
Truck:
Has a name
Has a starting point and itinerary
Has a capacity (how much cargo it can hold)
Has a list of depots to visit to pick up and offload cargo.
Will pick up cargo from a depot
Will drop off cargo at a depot
Once it has reached the last depot it will have finished its journey and therefore stop
Your program will be checked against a simulation involving these classes, assuming you have implemented it correctly. Each class provides comments as what the method needs to do and return. It is advised that you test your classes.
** I have already finished the cargo part, May I please know how to complete the depot.py and truck.py? Thank you. **
Here are the depot.py and truck.py:
depot.py
truck.py
1 class Depot: 2 def __init_(self, name) 4 Initialises the depot 6 7 8 pass def get_name (self) 10 Returns the name of the depot 12 pass 13 def get contents (self) 15 16 Returns the contents of the depot 17 18 pass 19 20 21 def add_cargo (self, cargo): Adds cargo to the depot 23 pass 26 def take_cargo (self, truck) 27 28 Takes cargo from a truck intended for this depot 29 pass 31 32 def give_cargo (self, truck): Gives cargo to a truck intended for another depot 35 36 pass 1 class Depot: 2 def __init_(self, name) 4 Initialises the depot 6 7 8 pass def get_name (self) 10 Returns the name of the depot 12 pass 13 def get contents (self) 15 16 Returns the contents of the depot 17 18 pass 19 20 21 def add_cargo (self, cargo): Adds cargo to the depot 23 pass 26 def take_cargo (self, truck) 27 28 Takes cargo from a truck intended for this depot 29 pass 31 32 def give_cargo (self, truck): Gives cargo to a truck intended for another depot 35 36 pass
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started