Advertisement
Nenogzar

stamp_catalog

Feb 25th, 2024
699
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.80 KB | None | 0 0
  1. class Stamps:
  2.     all_stamps = []
  3.  
  4.     def __init__(self, validation_date: str, BG, MI, SC, Ivert, SG):
  5.  
  6.         self.validation_date = validation_date
  7.         self.BG = BG
  8.         self.MI = MI
  9.         self.SC = SC
  10.         self.Ivert = Ivert
  11.         self.SG = SG
  12.  
  13.         Stamps.all_stamps.append(self)
  14.  
  15.     def year_id(self):
  16.         day, month, year = map(str, self.validation_date.split('.'))
  17.         validation_year = year
  18.         return validation_year
  19.  
  20.     def period_info(self):
  21.         validation_year = self.year_id()  # Променена тук
  22.         period_id = ""
  23.         period = ""
  24.         if int(validation_year) <= 1908:
  25.             period = "Principality of Bulgaria"
  26.             period_id = 1
  27.         elif int(validation_year) <= 1946:
  28.             period = "Kingdom of Bulgaria"
  29.             period_id = 2
  30.         elif int(validation_year) <= 1999:
  31.             period = "People's Republic of Bulgaria"
  32.             period_id = 3
  33.         else:
  34.             period = "Republic of Bulgaria"
  35.             period_id = 4
  36.         return period_id, period
  37.  
  38.     def ID_generator(self):
  39.         validation_year = self.year_id()  # Променена тук
  40.         stamp_id = f"{period_id}_{validation_year}_{self.BG}"
  41.         return stamp_id
  42.  
  43.  
  44. # Create an instance of Stamps
  45. stamp1 = Stamps("01.05.1879", 1, 1, 1, 1, 1)
  46. stamp2 = Stamps("01.05.1879", 2, 2, 2, 2, 2)
  47. stamp348 = Stamps("25.02.1938", 348, 338, 324, 348, 326)
  48. stamp878 = Stamps("11.11.1952", 878, 836, 779, 836, 856)
  49.  
  50. for stamp in Stamps.all_stamps:
  51.     period_id, period = stamp.period_info()
  52.     print(
  53.         f"Postmark number according to BG catalog {stamp.BG} is an edition in {period} and gets an ID: {stamp.ID_generator()}. \n"
  54.         f"It was issued during the period of {period_id}\n"
  55.         f"__________")
  56.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement