Пример #1
0
    def insertarElemento(self, elemento, posicion):
        if posicion == 0:
            self.agregarElemento(elemento)
        else:
            aux = self.__comienzo
            i = 0
            elemento = Nodo(elemento)

            while i < posicion and aux != None:
                anterior = aux
                aux = aux.getSiguiente()
                i += 1

            if i > posicion:
                raise IndexError
            else:
                elemento.setSiguiente(aux)
                anterior.setSiguiente(elemento)
                self.__tope += 1
Пример #2
0
 def InsertarVehiculo(self,pos,elemento):
     try:
         if(pos>=0 and pos<=self.__tope):
             nodo=Nodo(elemento)
             if(pos==0):
                 nodo.setSiguiente(self.__comienzo)
                 self.__comienzo=nodo
                 self.__tope+=1
             else:
                 num=1
                 aux=self.__comienzo
                 while(num<pos):
                     aux=aux.getSiguiente()
                     num+=1
                 nodo.setSiguiente(aux.getSiguiente())
                 aux.setSiguiente(nodo)
                 self.__tope+=1    
             os.system('cls')
             print ("*** VEHICULO INSERTADO CON EXITO ***")   
             time.sleep(1)
         else:
                 raise IndexError()
     except IndexError:
         print('Posicion Fuera De Rango')
         time.sleep(1)
Пример #3
0
 def InsertarAgente(self, pos, Agente):
     try:
         if (pos <= self.__tope):
             nodo = Nodo(Agente)
             if (pos == 0):
                 nodo.setSiguiente(self.__comienzo)
                 self.__comienzo = nodo
                 self.__tope += 1
                 os.system('cls')
                 print("*** AGENTE INSERTADO CON EXITO ***")
                 time.sleep(1)
             else:
                 num = 1
                 aux = self.__comienzo
                 while (num < pos):
                     aux = aux.getSiguiente()
                     num += 1
                 nodo.setSiguiente(aux.getSiguiente())
                 aux.setSiguiente(nodo)
                 self.__tope += 1
                 os.system('cls')
                 print("*** AGENTE INSERTADO CON EXITO ***")
                 time.sleep(1)
     except IndexError:
         print('Posicion Fuera De Rango')
         time.sleep(1)
Пример #4
0
 def AgregarVehiculo(self,vehiculo):
     try:
         if(type(vehiculo)==Usado or type(vehiculo)==Nuevo):
             nodo=Nodo(vehiculo)
             if(self.__comienzo==None):
                     nodo.setSiguiente(self.__comienzo)
                     self.__comienzo=nodo
                     self.__actual=nodo
                     self.__tope+=1
             else:
                 aux=self.__comienzo
                 while(aux.getSiguiente()!=None):
                     aux=aux.getSiguiente()
                 nodo.setSiguiente(aux.getSiguiente())
                 aux.setSiguiente(nodo)
                 self.__tope+=1
             os.system('cls')
             print ("*** VEHICULO AGREGADO CON EXITO ***")   
             time.sleep(1)
         else:
             raise TypeError()
     except TypeError:
         print('No es un vehiculo')     
Пример #5
0
 def AgregarAgente(self, persona):
     try:
         if (type(persona) == PersonalApoyo or type(persona) == Docente
                 or type(persona) == Investigador
                 or type(persona) == DocenteInvestigador):
             nodo = Nodo(persona)
             if (self.__comienzo == None):
                 nodo.setSiguiente(self.__comienzo)
                 self.__comienzo = nodo
                 self.__actual = nodo
                 self.__tope += 1
             else:
                 aux = self.__comienzo
                 while (aux.getSiguiente() != None):
                     aux = aux.getSiguiente()
                 nodo.setSiguiente(aux.getSiguiente())
                 aux.setSiguiente(nodo)
                 self.__tope += 1
             os.system('cls')
             print("*** AGENTE AGREGADO CON EXITO ***")
             time.sleep(1)
     except TypeError:
         print('No es una persona')
Пример #6
0
 def agregarElemento(self, dato):
     nodo = Nodo(dato)
     nodo.setSiguiente(self.__comienzo)
     self.__comienzo = nodo
     self.__actual = nodo
     self.__tope += 1