Professional Documents
Culture Documents
(Padin-Alcantara) - Midterm - Project
(Padin-Alcantara) - Midterm - Project
Michael Padin,
Allen Alvin Alcantara
# 1. instantiate node
# 2. Put the data in it
new_node = Node(new_img)
print('-----IMAGES IN ALBUMS------\n')
print('forward direction')
print('[', end='')
while node:
print(f'{node.data}', end='')
last = node
node = node.next
if node is not None:
print(' --> ', end='') # ignore print only
print(']\n')
print('reverse direction')
print('[', end='')
while last is not None:
print(f'{last.data}', end='')
last = last.prev
if last is not None:
print(' --> ', end='') # ignore print only
print(']\n')
def num_of_images(self):
return self.size
if __name__ == "__main__":
choice = None
pictures = Albums()
while choice != 0:
print("\n\n=============================================")
print('Albums - Doubly Linked List Implementation\n')
print('0. exit \t\t2. Delete Image \t4. total number of images\n1. Add Image
\t3. Display Images')
print("=============================================\n")
# Close program
if choice == 0:
print('closing program...')
# Add Image
elif choice == 1:
numOfImages = int(input('how many images you want to add? '))
# Delete Image
elif choice == 2:
# check if there are images in album
if pictures.is_album_empty():
print('Albums is empty. Please add an image')
else:
pictures.display_images(pictures.head)
imgName = str(input('Enter Image name to delete: '))
pictures.delete_image(imgName)
# Display Images
elif choice == 3:
if pictures.is_album_empty():
print('Albums is empty. Please add an image')
else:
pictures.display_images(pictures.head)
elif choice == 4:
print(f'total number of images on the albums: {pictures.num_of_images()}')
else:
print('Invalid input! please try again....\n')
OUTPUT