Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Calculator:
- def __init__(self, limit):
- self.limit = limit
- self.count = 0
- self.records = []
- def add_record(self, record):
- self.records.append(record)
- def print_comments(self):
- for record in self.records:
- print(record.comment)
- def get_balance(self):
- return self.limit - sum([record.amount for record in self.records])
- class Record:
- def __init__(self, amount, comment, date = ' '):
- self.amount = amount
- self.comment = comment
- def show(self):
- print(f'Создана запись! Затраты: {self.amount}, комментарий: "{self.comment}"')
- calc = Calculator(1000)
- calc.add_record(Record(300, 'Starbucks'))
- calc.add_record(Record(200, 'MTC mobile'))
- calc.print_comments()
- calc.get_balance()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement