Untitled

mail@pastecode.io avatar
unknown
python
2 years ago
2.5 kB
2
Indexable
Never
# სავარჯიშო 1, 2

class Vaccine:
    def __init__(self, vaccine_name, vaccine_amount, min_age, doze_amount, manufacturer_country):
        self.vaccine_name = vaccine_name
        self.vaccine_amount = vaccine_amount
        self.min_age = min_age
        self.doze_amount = doze_amount
        self.manufacturer_country = manufacturer_country

    def __str__(self):
        return f'Vaccine Name: {self.vaccine_name}, ' \
               f'Vaccine Amount: {self.vaccine_amount}, ' \
               f'Minimum Age: {self.min_age}, ' \
               f'Doze Amount: {self.doze_amount}, ' \
               f'Manufacturer Country: {self.manufacturer_country}'


#######################################################################################################################
# სავარჯიშო 3, 4, 5


class Citizen:
    def __init__(self, identity_number, name, age, injected_vaccine: Vaccine = None, injected_vaccine_amount=0):
        self.identity_number = identity_number
        self.name = name
        self.age = age
        self.injected_vaccine = injected_vaccine
        self.injected_vaccine_amount = injected_vaccine_amount

    def __str__(self):
        return f'Identity Number: {self.identity_number}, ' \
               f'Name: {self.name}, ' \
               f'Injected Vaccine: {self.injected_vaccine}, ' \
               f'Injected Vaccine Amount: {self.injected_vaccine_amount}'

    def process_citizen(self, vaccine: Vaccine):
        if self.age < vaccine.min_age:
            return print(f'ვაქცინისათვის მინიმალური ასაკი არის {vaccine.min_age}')

        if vaccine.vaccine_amount == 0:
            return print('ვაქცინის რაოდენობა ამოიწურა')

        if self.injected_vaccine_amount < vaccine.doze_amount:
            self.injected_vaccine = vaccine
            self.injected_vaccine_amount += 1
            vaccine.vaccine_amount -= 1
        else:
            return print('თქვენი დოზების რაოდენობა ამოწურულია')


#######################################################################################################################
# სავარჯიშო 6

vaccineObj = Vaccine('Pfizer', 12, 10, 1, 'Germany')
print(vaccineObj)

citizenObj = Citizen('01024078943', 'CitizenName', 11)
citizenObj.process_citizen(vaccineObj)
print(citizenObj)