Guruh talabasi Qayimov Jamshidning


Download 0.66 Mb.
bet1/2
Sana03.12.2020
Hajmi0.66 Mb.
#157850
  1   2
Bog'liq
315-18 1-lab


315-18 guruh talabasi

Qayimov Jamshidning

Dasturlash uslublari va piramidalari fanidan

1- labaratoriya ishi

class Card:

  """PLastik karta ma'lumotlari"""

  def __init__(self, holder, number, expire, balance=0):

    self.holder = holder

    self.number = number

    self.expire = expire

    self.balance = balance
  def get_balance(self):

    return self.balance


  def set_balance(self, balance):

    self.balance += balance

    return self.balance
  def get_info(self):

    return f"Holder: {self.holder}\nCard number: {self.number}\nExpire date: {self.expire}\nBalance: {self.balance}"

class Wallet:

  """Elektron hamyon obyekt generatori"""

  def __init__(self, full_name, phone, card):

    self.full_name = full_name

    self.phone = phone

    self.card = card

  def transfer(self, card, amount):

    if amount <= self.card.get_balance():

      card.set_balance(amount)

      return "Money transfered"

    else:

      return "Money not enogh to transfer"


  def check_balance(self):

    return self.card.get_balance()


  def pay_for_service(self, service, amount):

    # todo do some checking and pay self.card.set_balance(-amount)

    return f"{amount} $ payed for service {service}"
  def get_history(self):

    return [

      "2.10.2020: -200,000 $",

      "9.10.2020: 310,600 $",

      "19.10.2020: 11,045 $",

      "29.10.2020: -1,072 $",

    ]
m=Card('Jamshid',777,3,'100 $')

print(m.get_info())


w=Wallet('Qayimov Jamshid',777,'100$')

print(w.pay_for_service('Amazon','100$'))







Download 0.66 Mb.

Do'stlaringiz bilan baham:
  1   2




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling