Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update IBank_part1_1.py #3596

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 35 additions & 2 deletions Module8/practice/IBank/IBank_part1_1.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
from typing import List
import pytest


class Account:
def __init__(self, name: str, passport: str, phone_number: str, start_balance: int = 0):
self.name = name
Expand All @@ -9,13 +13,42 @@ def full_info(self) -> str:
"""
Полная информация о счете в формате: "Иван баланс: 100 руб. паспорт: 3200 123456 т.+7-900-200-02-03"
"""
return f"..."
return f"{self.name} баланс: {self.balance} руб. паспорт: {self.passport} т.{self.phone_number}"

def __repr__(self) -> str:
"""
:return: Информацию о счете в виде строки в формате "Иван баланс: 100 руб."
"""
return f"..."
return f"{self.name} баланс: {self.balance} руб."

def __str__(self) -> str:
"""
:return: Информацию о счете в виде строки в формате "Иван баланс: 100 руб."
"""
return self.__repr__()

def deposit(self, amount: int) -> None:
"""
Пополнение баланса на сумму amount
"""
self.balance += amount

def withdraw(self, amount: int) -> None:
"""
Снятие со счета суммы amount, если это возможно
"""
if amount > self.balance:
raise ValueError("Недостаточно средств на счете")
self.balance -= amount

def transfer(self, other: "Account", amount: int) -> None:
"""
Перевод суммы amount с данного счета на счет other, если это возможно
"""
if amount > self.balance:
raise ValueError("Недостаточно средств на счете")
self.balance -= amount
other.balance += amount


account1 = Account("Иван", "3230 634563", "+7-900-765-12-34")
Expand Down