Advertisement
jabela

Untitled

Apr 29th, 2024 (edited)
640
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.17 KB | None | 0 0
  1. class Plane:
  2.  
  3.     def __init__(self, planeName, planeType):
  4.         self.__planeName = planeName
  5.         self.__planeType = planeType
  6.  
  7.     def getName(self):
  8.         return self.__planeName
  9.  
  10.     def getType(self):
  11.         return self.__planeType
  12.  
  13.     def __str__(self):
  14.         return f"Name: {self.__planeName}, Type: {self.__planeType}"
  15.  
  16. # Initializing the parking as a 2D list
  17. parking = []
  18.  
  19. # Adding planes to rows
  20. rowOne = [Plane("BCX 292", "Embrarer 195"), Plane("BCZ 182", "Embrarer 190"), Plane("BHT 894", "Embrarer 195")]
  21. rowTwo = [Plane("XSK 922", "Airbus 330"), Plane("IUY 293", "Airbus 350"), Plane("NFF 912", "Boeing 777"), Plane("XSJ 883", "Airbus 350")]
  22. rowThree = [Plane("KSJ 948", "Airbus 380"), Plane("PSJ 829", "Boeing 747")]
  23.  
  24. # Adding rows to the parking lot
  25. parking.append(rowOne)
  26. parking.append(rowTwo)
  27. parking.append(rowThree)
  28.  
  29. # Removing a specific plane from rowOne
  30. del parking[0][1]
  31.  
  32. # Printing information for planes specifically of the "Airbus" type
  33. for row in parking:
  34.     for plane in row:
  35.         if "Airbus" in plane.getType():
  36.             print(plane, end=" ")
  37.     print("")  # To ensure proper formatting with a newline between rows
  38.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement