forked from abhaysamantni/Python_MidTerm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
hardwareSet.py
49 lines (36 loc) · 1.18 KB
/
hardwareSet.py
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
# The DroneSet defines a class that stores attributes and methods pertaining to various drone sets
import math
class HWSet:
def __init__(self, qty):
self.__capacity = qty
self.__availability = self.__capacity
self.__checkedout = 0
def check_out(self, qty):
if (qty < self.__availability):
self.__availability = self.__availability - qty
self.__checkedout += qty
return 0
else:
self.__checkedout += self.__availability
self.__availability = 0
return -1
def check_in(self, qty):
if ((qty >= 0) and (qty < self.__checkedout)):
self.__availability += qty
return 0
else:
return -1
def get_availability(self):
return self.__availability
def get_capacity(self):
return self.__capacity
def get_checkedout_qty(self):
return self.__checkedout
class DroneSet(HWSet):
def __init__(self, qty, payload):
HWSet.__init__(self, qty)
self.__payload = payload
def get_payload(self):
return self.__payload
def set_payload(self, payload):
self.__payload = payload