Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Description A delivery company has two methods of delivery - ground vehicles and air drones. The delivery area is covered by a grid of

image text in transcribed

Description A delivery company has two methods of delivery - ground vehicles and air drones. The delivery area is covered by a grid of roads stretching from north to south and from east to west every kilometer. A ground vehicle can move on the roads - along X axis or Y axis, whereas drone can fly directly to the destination. Both devices receive coordinates for delivery and relocate accordingly. The company keeps track of a total distance traveled to deliver all packages. Y 1,3 2,3 3, 3 H 1,2 2,2 3, 2 2,1 1, 1 3, 1 X Introduce an interface named Delivery to describe a delivery device with a method deliver To(int x, int y). The method would return the distance traveled from the last position of the vehicle or drone to delivery destination. Create two independent classes for ground and air delivery that implement the interface. The program should first accept a delivery type (either 'ground' or 'air') and a sequence of delivery destinations as a pair of coordinates terminated with the word 'end', for example: air 23 55 41 72 53 end The delivery starts from coordinates (0, 0) and then visits all the destinations in the sequence. Travel distance for vehicle is Travel distance for drone is Optimize the code and utilize the concept of polymorphism when using objects of either vehicle or drone. Create a custom exception class that should be thrown in case an invalid delivery type is entered. The program should handle all the exceptions (none thrown by the main method), including those resulting from incorrect user's input of non-numerical coordinates. The program should print out the total distance traveled on the delivery route.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

Output ... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Auditing and Assurance services an integrated approach

Authors: Alvin a. arens, Randal j. elder, Mark s. Beasley

14th Edition

133081605, 132575957, 9780133081602, 978-0132575959

More Books

Students also viewed these Programming questions