00:01
In this question, our program will demonstrate the use of polymorphism in the context of the great lakes shipping company.
00:18
So, it stimulates scenario where there are boats, trucks and vans that can be fueled performing operations like loading and unloading cargo and provide information about the attributes.
00:32
So, let us look at how we will write this program.
00:36
For that, i will proceed to a compiler.
00:42
So, here first, i'll import java and arrow list.
00:47
Next thing is we created this array list which we will give it as vehicles further to share the instance.
01:06
So, i'll show you how that is written.
01:08
So, here we create an array list called vehicles to store the instance of vehicles that implement the fluable interface.
01:19
This allows us to store objects of different classes that implement the fluable interface.
01:27
So, now we will create for boat, truck and van.
01:36
So, for that, i will add this.
01:40
So, here we create the instances of boat, truck and van classes.
01:44
Then we initializing them with the specific attributes such as captain, then driver name that is driver joe and range capacity, fuel galleon.
01:59
So, these classes extend the fluable interface and provide their own implementation of methods defined in the interface.
02:07
So, we add the instances of boats, truck and vans to the vehicles list.
02:16
So, now next step is that we have to add vehicles to the list that we create here.
02:29
Next thing we'll do is we'll create a for loop through the vehicles and performing actions.
02:36
For that, we'll use a for loop like this that will help us...