Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class CreditDepartament: # банк
- def __init__(self, base_rate):
- self.base_rate = base_rate # базовая ставка
- self.clients = [] # клиенты банка
- def add_client(self, client): # добавить клиента
- self.clients.append(client)
- def credit_decision(self, client): # решение по кредиту
- for item in self.clients:
- if item == client: # если клиент найден в списке вывод решения
- return "Выдать кредит: " + client.about() + ". Процентная ставка: " + str(round(self.base_rate + client.personal_rate(),2))
- return "Такого клиента нет"
- def credit_decision(self): # решение по кредиту
- for client in self.clients:
- print("Выдать кредит: " + client.about() + ". Процентная ставка: " + str(round(self.base_rate + client.personal_rate(),2)))
- class Client: # базовый класс клиент
- def __init__(self, name, age, rating):
- self._name = name # имя
- self._age = age # возраст
- self._rating = rating # кредитный рейтинг
- def personal_rate(self): # расчет рейтинга
- return 1.0 / self._rating + 0.01 * self._age
- def about(self): # вывод информации о клиенте
- return "Клиент: " + self._name + " ,Возраст: " + str(self._age) + " лет, Категория:"
- class Employee(Client): # наследуемый класс Сотрудник
- def __init__(self, name, age, rating, discount):
- Client.__init__(self, name, age, rating)
- self.discount = discount
- def about(self):
- return str(Client.about(self)) + str(" Сотрудник")
- def personal_rate(self):
- return Client.personal_rate(self) - self.discount * 1.8
- class Privileges(Client): # наследуемый класс Льготник
- def __init__(self, name, age, rating, discount):
- Client.__init__(self, name, age, rating)
- self.discount = discount
- def about(self):
- return str(Client.about(self)) + str(" Льготник")
- def personal_rate(self):
- return Client.personal_rate(self) - self.discount * 1.2
- class OrdinaryCitizen(Client): # наследуемый класс Обычный гражданин
- def __init__(self, name, age, rating, discount):
- Client.__init__(self, name, age, rating)
- self.discount = discount
- def about(self):
- return str(Client.about(self)) + str(" Обычный гражданин")
- def personal_rate(self):
- return Client.personal_rate(self) + self.discount * 0.1
- class CitizenBadHistory(Client): # наследуемый класс Гражданин с плохой информацией
- def __init__(self, name, age, rating, discount):
- Client.__init__(self, name, age, rating)
- self.discount = discount
- def about(self):
- return str(Client.about(self)) + str(" Гражданин с плохой историей")
- def personal_rate(self):
- return Client.personal_rate(self) + self.discount * 3
- def print_menu():
- print('1. Добавить сотрудника')
- print('2. Добавить льготника')
- print('3. Добавить обычного гражданина')
- print('4. Добавить гражданина с плохой историей')
- print('5. Вывести информацию')
- print('0. Выход')
- def input_data_client():
- print('Name: ')
- name = input()
- print('Age: ')
- age = int(input())
- print('Rating: ')
- rating = int(input())
- print('Discount: ')
- discount = int(input())
- return [ name, age, rating, discount ]
- command = -1
- dep = CreditDepartament(6.5)
- while command != 0:
- print_menu()
- print('Введите команду: ')
- command = int(input())
- if command == 1:
- data = input_data_client()
- dep.add_client(Employee(data[0], data[1], data[2], data[3]))
- elif command == 2:
- data = input_data_client()
- dep.add_client(Privileges(data[0], data[1], data[2], data[3]))
- elif command == 3:
- data = input_data_client()
- dep.add_client(OrdinaryCitizen(data[0], data[1], data[2], data[3]))
- elif command == 4:
- data = input_data_client()
- dep.add_client(CitizenBadHistory(data[0], data[1], data[2], data[3]))
- elif command == 5:
- print(dep.credit_decision())
Advertisement
Add Comment
Please, Sign In to add comment