-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlogistics.java
More file actions
77 lines (57 loc) · 1.28 KB
/
Copy pathlogistics.java
File metadata and controls
77 lines (57 loc) · 1.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
abstract class Transport
{
String trackingID;
String destination;
Transport(String tid)
{
trackingID = tid;
}
abstract void dispatch();
}
interface GPS
{
void getCoordinates();
}
interface Autonomous
{
void selfNavigate();
}
class deliveryDrone extends Transport implements GPS, Autonomous
{
deliveryDrone(String tid)
{
super(tid);
}
public void dispatch()
{
System.out.println("Drone " + trackingID + " taking off...");
}
public void getCoordinates()
{
System.out.println("40.7128° N, 74.0060° W");
}
public void selfNavigate()
{
System.out.println("Drone navigating autonomously...");
}
}
public class logistics {
public static void main(String[] args) {
//1
Transport t = new deliveryDrone("D101");
t.dispatch();
//2
GPS g = new deliveryDrone("D101");
g.getCoordinates();
// TC 3
if (t instanceof GPS)
{
System.out.println("t supports GPS");
((GPS) t).getCoordinates();
}
else
{
System.out.println("t does not support GPS");
}
}
}