Assuming flyTo moves drone but delivery requires destination set first.
medium
A. flyTo() should be flyToDestination()
B. Package not set before delivery
C. Missing destination set before flying
D. deliver() method does not exist
Solution
Step 1: Check method order and requirements
Delivery requires setting destination before flying. Here, destination is not set explicitly.
Step 2: Identify missing step
Code calls flyTo('Office') but does not set destination property, which delivery depends on.
Final Answer:
Missing destination set before flying -> Option C
Quick Check:
Destination must be set before flyTo and deliver [OK]
Hint: Always set destination before flying and delivering [OK]
Common Mistakes:
Skipping destination setup
Assuming flyTo sets destination automatically
Confusing method names
5. You want to program a drone to deliver multiple packages to different destinations in sequence. Which approach best fits this task?
hard
A. Use a loop to set each package and destination, then fly and deliver each time
B. Set all packages at once and fly to one destination only
C. Fly randomly and drop packages without setting destinations
D. Deliver packages without flying
Solution
Step 1: Understand multi-package delivery needs
Each package must be assigned a destination and delivered one by one.
Step 2: Choose correct programming structure
A loop allows repeating setPackage, setDestination, fly, and deliver steps for each package.
Step 3: Evaluate other options
Set all packages at once and fly to one destination only ignores multiple destinations. Fly randomly and drop packages without setting destinations is unsafe and random. Deliver packages without flying skips flying, which is needed.
Final Answer:
Use a loop to set each package and destination, then fly and deliver each time -> Option A
Quick Check:
Loop for sequential deliveries [OK]
Hint: Loop through packages and destinations for multiple deliveries [OK]
Common Mistakes:
Trying to deliver all packages at once
Ignoring destination assignment
Skipping flying step
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.