-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDrone.m
57 lines (44 loc) · 1.42 KB
/
Drone.m
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
classdef Drone
%DRONE Summary of this class goes here
% Detailed explanation goes here
properties
Id
Range
X_coord
Y_coord
end
methods
function obj = Drone(id, range, x, y)
%DRONE Construct an instance of this class
% Detailed explanation goes here
obj.Id = id;
obj.Range = range;
obj.X_coord = x;
obj.Y_coord = y;
end
function nextMove = selectMove(obj, dest_x, dest_y)
%METHOD1 Summary of this method goes here
% Detailed explanation goes here
% Move East
if obj.X_coord - dest_x < 0
obj.X_coord = obj.X_coord + 1;
% Move West
elseif obj.X_coord - dest_x > 0
obj.X_coord = obj.X_coord - 1;
% Move North
elseif obj.Y_coord - dest_y < 0
obj.Y_coord = obj.Y_coord + 1;
% Move South
elseif obj.Y_coord - dest_y > 0
obj.Y_coord = obj.Y_coord - 1;
end
nextMove = obj;
end
function x_coord = getX(obj)
x_coord = obj.X_coord;
end
function y_coord = getY(obj)
y_coord = obj.Y_coord;
end
end
end