I have 3 classes: Nodo.py, Lista.py and ListaEnlazada.py
The code of Nodo is:
class Nodo:
def __init__(self, dato=None , nodo = None): #@Method
self._dato = dato
self._siguiente = nodo
def setDato(self, dato): #@Method
self._dato = dato
def getDato(self): #@Method
return self._dato
def setSiguiente(self,nodo): #@Method
self._siguiente = nodo
def getSiguiente(self): #@Method
return self._siguiente
The code of Lista is:
class Lista:
def __init__(self): #@Method
self._tamanio=0
def elemento(self,pos): #@Method
pass
def agregar(self,elem,pos): #@Method
pass
def eliminar(sel,pos): #@Method
pass
Finally, the code of ListaEnlazada is:
import Nodo
import Lista
class ListaEnlazada(Lista):
def __init__(self): #@Method
Lista.__init__(self)
self.__inicio = None
def esVacia(self): #@Method
return self.__inicio == None
def elemento(self,pos): #@Method
pos = pos-1
if(self.__inicio == None):
return None
else:
aux = self.__inicio
while(aux.getSiguiente() != None and 0<=pos):
aux = aux.getSiguiente()
pos -=1
return aux.getDato()
def agregar(self,elem,pos): #@Method
nuevo = Nodo(elem,None)
if(self.__inicio == None):
self.__inicio = nuevo
else:
aux = self.__inicio
while(aux.getSiguiente() != None):
aux = aux.getSiguiente()
aux.setSiguiente(nuevo)
self._tamanio +=1
def eliminar(self,pos): #@Method
cont = 0
if(cont == pos):
self.__inicio = self.__inicio.getSiguiente()
self._tamanio -=1
else:
aux = self.__inicio
while(True):
cont += 1
if(cont==pos):
aux2 = aux.getSiguiente()
aux.setSiguiente(aux2.getSiguiente())
break
aux = aux.getSiguiente()
if(pos<cont):
print ("fuera de rango")
When I compile ListaEnlazada y get the next error:
TypeError: module.init() takes at most 2 arguments (3 given)
Which is the problem and how I can solve it?
Thanks!