Untitled


SUBMITTED BY: antoineh1

DATE: May 8, 2016, 10:03 p.m.

FORMAT: Text only

SIZE: 1.1 kB

HITS: 3765

  1. class data_array:
  2. def __init__(self):
  3. # initiates empty lists for each attribute
  4. self.number = []
  5. self.code = []
  6. self.connected = []
  7. self.reading = []
  8. self.location = []
  9. self.info_one = []
  10. self.info_two = []
  11. sensor = [None] * 16
  12. for ind in range(0, 16,1):
  13. # initiate the attributes
  14. sensor[ind] = data_array()
  15. for ind in range(0,16,1):
  16. # for loop to simulate reading data from a file
  17. sensor[ind].number = ind +1
  18. sensor[ind].code = "code" + str(ind +1)
  19. sensor[ind].connected = False
  20. sensor[ind].reading = 201 + ind
  21. sensor[ind].location = " where I found " + str(ind+1)
  22. sensor[ind].info_one = " infor_one for sensor " + str(ind+1)
  23. sensor[ind].info_two = " infor_two for sensor " + str(ind+1)
  24. for ind in range(0,16,1):
  25. # check data is accessable as intended
  26. print(sensor[ind].number, sensor[ind].code,
  27. sensor[ind].connected, sensor[ind].reading, sensor[ind].location,
  28. sensor[ind].info_one, sensor[ind].info_two)

comments powered by Disqus