mirror of
https://github.com/BreizhHardware/py_A2.git
synced 2026-03-18 21:30:52 +01:00
Fix
This commit is contained in:
@@ -73,8 +73,15 @@ class ListeChainee:
|
||||
self.tete = None
|
||||
|
||||
def __add__(self, other):
|
||||
current = self.tete
|
||||
while current.next:
|
||||
current = current.next
|
||||
current.next = other.tete
|
||||
return self
|
||||
current1 = self.tete
|
||||
current2 = other.tete
|
||||
LC = ListeChainee()
|
||||
while current1 or current2:
|
||||
val1 = current1.value if current1 else 0
|
||||
val2 = current2.value if current2 else 0
|
||||
LC.add_last(val1 + val2)
|
||||
if current1:
|
||||
current1 = current1.next
|
||||
if current2:
|
||||
current2 = current2.next
|
||||
return LC
|
||||
|
||||
@@ -21,9 +21,6 @@ def test_listechainee():
|
||||
LC.empty()
|
||||
print(LC.isEmpy())
|
||||
LC.printLinkedList()
|
||||
LC.add_first(1)
|
||||
LC.add_first(2)
|
||||
LC.add_first(2)
|
||||
LC.add_first(35)
|
||||
LC.add_last(44)
|
||||
LC.printLinkedList()
|
||||
@@ -34,6 +31,13 @@ def test_listechainee():
|
||||
LC2.printLinkedList()
|
||||
LC3 = LC + LC2
|
||||
LC3.printLinkedList()
|
||||
LC4 = ListeChainee()
|
||||
LC4.add_first(1)
|
||||
LC4.add_first(1)
|
||||
LC4.add_first(1)
|
||||
LC4.add_first(1)
|
||||
LC5 = LC3 + LC4
|
||||
LC5.printLinkedList()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
Reference in New Issue
Block a user