Kati
Rauemi

Rauemi

Rauemi

8A raumi 1

patengiRaraunga.rehitaTuakiri(hone)

patengiRaraunga.rehitaTuakiri(timoti)

patengiRaraunga.rehitaTuakiri(hemi)

patengiRaraunga.rehitaTuakiri(karena)

 

patengiRaraunga.rehitaMaraeTuhi(teAkaMatuaMaraeTuhi)

patengiRaraunga.rehitaMaraeTuhi(waipapaMaraeTuhi)

 

patengiRaraunga.takiMai(karena, waipapaMaraeTuhi, datetime(2018, 03, 13, 11, 32))

patengiRaraunga.takiMai(hemi, waipapaMaraeTuhi, datetime(2018, 03, 14, 20, 9))

patengiRaraunga.takiMai(hone, teAkaMatuaMaraeTuhi, datetime(2018, 03, 15, 7, 35

 8A Raumi 2

from datetime import datetime

 

# The class definition for a Tuakiri

class Tuakiri:

 def __init__(self, ingoa, whanau, tau):

  self.__ingoa = ingoa

  self.__whanau = whanau

  self.__tau = tau

 def tikiIngoa(self):

  return self.__ingoa + " " + self.__whanau

 def tikiTau(self):

  return self.__tau

 

# -----------------------------

 

# GlobalRegister, responsible for managing multiple Marae instances

class PatengiRaraunga:

 def __init__(self):

  self.__rarangiRehita = [] # listRegisteredPeople

  self.__rarangiMarae = [] # listMarae

 

 # Register Tuakiri

 def rehitaTuakiri(self, tuakiri):

  if (tuakiri in self.__rarangiRehita):

   # Tuakiri is already registered in the Global Register

   print "Kua rehita ke a " + tuakiri.tikiIngoa() + " i te Patengi Raraunga."

  else:

   # Tuakiri is now registered in the Global Register

   self.__rarangiRehita.append(tuakiri)

   print "Kua rehita inaianei a " + tuakiri.tikiIngoa() + " i te Patengi Raraunga."

 

 # Register Marae

 def rehitaMarae(self, marae):

  if (marae in self.__rarangiMarae):

   # Marae is already registered in the Global Register

   print "Kua rehita ke te Marae o " + marae.tikiMaraeIngoa() + " i te Patengi Raraunga."

  else:

   # Marae is now registered in the Global Register

   self.__rarangiMarae.append(marae)

   print "Kua rehita inaianei te Marae o " + marae.tikiMaraeIngoa() + " i te Patengi Raraunga."

 

 # Check in

 def takiMai(self, tuakiri, maraeCheckingInto, waInaianei):

 if (maraeCheckingInto not in self.__rarangiMarae):

  # Marae is not in Global Register. Needs to be registered first

  print "Kahore te Marae o " + maraeCheckingInto.tikiMaraeIngoa() + " i te Patengi Raraunga. Me rehita i te tuatahi."

 elif (tuakiri not in self.__rarangiRehita):

  # Tuakiri is not in Global Register. Needs to be registered first

  print "Kahore a " + tuakiri.tikiIngoa() + " i te Patengi Raraunga. Me rehita i te tuatahi."

 else:

  # Look into the other Marae.. in case the person is already checked in somewhere.

  for marae in self.__rarangiMarae:

   if (marae.keiReira(tuakiri)):

    # Check out the person from the other marae.

    marae.tango(tuakiri)

    print "Kua taki atu a " + tuakiri.tikiIngoa() + " i te Marae o " + marae.tikiMaraeIngoa() + "."

 

  # and finally check them in

  maraeCheckingInto.tapiri(tuakiri, waInaianei)

 

  # Tuakiri checked into Marae at time.

  print "I taki mai a " + tuakiri.tikiIngoa() + " ki " + maraeCheckingInto.tikiMaraeIngoa() + " i te " + waInaianei.strftime("%x, %I:%M%p")

 

  # Check out

  def takiAtu(self, tuakiri):

   if (tuakiri not in self.__rarangiRehita):

    # Tuakiri is not in Global Register. Needs to be registered first

    print "Kahore a " + tuakiri.tikiIngoa() + " i te Patengi Raraunga. Me rehita i te tuatahi."

   else:

    # find out which marae they are currently checked into, and check them out

    for marae in self.__rarangiMarae:

     if (marae.keiReira(tuakiri)):

      marae.tango(tuakiri)

      print "Kua taki atu a " + tuakiri.tikiIngoa() + " i te Marae o " + marae.tikiMaraeIngoa() + "."

      return

 

    # otherwise they are not checked in anywhere

    print "Kahore i taki mai a " + tuakiri.tikiIngoa()

 

  # number Tuakiri registered

  def tokomahaTuakiriRehita(self):

   return len(self.__rarangiRehita)

 

  # number Tuakiri missing

  def tokomahaTuakiriNgaro(self):

   tokomahaTakiMai = 0;

   for marae in self.__rarangiMarae:

    tokomahaTakiMai += marae.tauKeiRoto()

    return self.tokomahaTuakiriRehita() - tokomahaTakiMai

 

  # print Tuakiri's current location

  def taWahiInaianei(self, tuakiri):

   keiHea = self.kimiWahi(tuakiri)

   if (keiHea == None):

    # Tuakiri is currently missing

    print "Kei te ngaro a " + tuakiri.tikiIngoa()

   else:

     # Tuakiri is currently at this marae

     print "Kei " + keiHea.tikiMaraeIngoa() + " a " + tuakiri.tikiIngoa() + " inaianei."

 

  # findLocation(tuakiri)

  def kimiWahi(self, tuakiri):

   for marae in self.__rarangiMarae:

    if (marae.keiReira(tuakiri)):

     return marae

    return None

 

  # prints whoIsMissing

  def hungaINgaro(self):

    # number of tuakiri missing

    ngaro = self.tokomahaTuakiriNgaro()

    if (ngaro == 0):

     # No one is ngaro, everyone has checked in.

     print "Kua taki mai te katoa. Kahore tetahi i te ngaro."

     return

    elif (ngaro == 1) :

     # There is one tuakiri missing

     print "Kei te ngaro tetahi i te rarangi ingoa:",

    elif (ngaro <= 9):

     # There are 2-9 tuakiri missing

     print "Kei te ngaro te toko "+ str(ngaro)+" o nga tangata i te rarangi ingoa:",

    else:

     # There are more than 9 tuakiri missing

     print "Kei te ngaro te "+ str(ngaro)+" o nga tangata i te rarangi ingoa:",

    count = 1;

    for tuakiri in self.__rarangiRehita:

     if (self.kimiWahi(tuakiri) == None):

      print "("+str(count)+") "+tuakiri.tikiIngoa(),

      if (count < ngaro):

       print ",",

      count+=1

    print

# -----------------------------

 

# There is an instance of this class for each Marae

# This class is treated like a specialised data structure

# We are not performing any safety/error checks here. We leave that for the PatengiRaraunga

class Marae:

 def __init__(self, maraeIngoa):

  self.__maraeIngoa = maraeIngoa # maraeName

  self.__iTaeMai = [] # inAttendance

  self.__wa = [] # timeArrived

 

 # getMaraeName

 def tikiMaraeIngoa(self):

  return self.__maraeIgnoa

 

 # add(person, timeNow)

 def tapiri(self, tuakiri, waInaianei):

  if ( tuakiri not in self.__iTaeMai ):

   self.__iTaeMai.append(tuakiri)

   self.__wa.append(waInaianei)

 

 # remove(person)

 def tango(self, tuakiri):

  if ( tuakiri in self.__iTaeMai ):

   indexToRemove = self.__iTaeMai.index(tuakiri, )

   del self.__iTaeMai[indexToRemove]

   del self.__wa[indexToRemove]

 

 # isPresent(person)

 def keiReira(self, tuakiri):

  return tuakiri in self.__iTaeMai

 

 # numberPeoplePresent

 def tauKeiRoto(self):

  return len(self.__iTaeMai)

 

 # -----------------------------

 

 patengiRaraunga = PatengiRaraunga()

 

 # define and register Tuakiri

 hone = Tuakiri("Hone", "Piwari", 35)

 timoti = Tuakiri("Timoti", "Graham", 15)

 hemi = Tuakiri("Hemi", "Pumau", 18)

 karena = Tuakiri("Karena", "Hika", 47)

 patengiRaraunga.rehitaTuakiri(hone)

 patengiRaraunga.rehitaTuakiri(timoti)

 patengiRaraunga.rehitaTuakiri(hemi)

 patengiRaraunga.rehitaTuakiri(karena)

 

 # define and register Marae

 teAkaMatuaMaraeTuhi = Marae("Te Aka Matua")

 waipapaMaraeTuhi = Marae("Waipapa Marae")

 patengiRaraunga.rehitaMarae(teAkaMatuaMaraeTuhi)

 patengiRaraunga.rehitaMarae(waipapaMaraeTuhi)

 print

 

 # Hika checks in at 11:32am on 13th March 2018

 patengiRaraunga.takiMai(karena, waipapaMaraeTuhi, datetime(2018, 03, 13, 11, 32))

 

 # Graham checks in at 8:09pm on 13th March 2018

 patengiRaraunga.takiMai(hemi, waipapaMaraeTuhi, datetime(2018, 03, 14, 20, 9))

 

 # Piwari checks in at 7:35am on 15th March 2018

 patengiRaraunga.takiMai(hone, teAkaMatuaMaraeTuhi, datetime(2018, 03, 15, 7, 35))

 

 print

 patengiRaraunga.taWahiInaianei(hone)

 patengiRaraunga.taWahiInaianei(timoti)

 patengiRaraunga.taWahiInaianei(hemi)

 patengiRaraunga.taWahiInaianei(karena)

 

 print

 # Total number of tuakiri to account for

 print "Te tokomaha o nga tangata kia kautehia: " + str(patengiRaraunga.tokomahaTuakiriRehita())

 

 # Total number of tuakiri that have not been accounted for

 print "Te tokomaha o nga tangata kahore ano kia kautehia: " + str(patengiRaraunga.tokomahaTuakiriNgaro())

 print

 

 patengiRaraunga.hungaINgaro()