forked from Ranabetuluzun/Python_Modul_Week_5
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathic_week_5_5.py
More file actions
62 lines (54 loc) · 2.07 KB
/
ic_week_5_5.py
File metadata and controls
62 lines (54 loc) · 2.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# Müşteri Bilgileri Sınıf Tanımı
class Customer:
def __init__(self, name, surname, tc_identification, phone):
self.name = name
self.surname = surname
self.tc_identification = tc_identification
self.phone = phone
# Müşteri bilgilerini yazdırma metodu
def display_information(self):
print(f"Ad: {self.name}")
print(f"Soyad: {self.surname}")
print(f"TC Kimlik No: {self.tc_identification}")
print(f"Telefon: {self.phone}")
# Banka Hesabı Sınıf Tanımı (Müşteri bilgileri miras alındı)
class Account(Customer): # Miras alındı
def __init__(self, name, surname, tc_identification, phone, account_number, balance=0):
super().__init__(name, surname, tc_identification, phone) # Üst sınıfın (Customer) init'ini çağır
self.account_number = account_number
self.balance = balance
# Depozito için metot
def deposit(self, amount):
if amount > 0:
self.balance += amount
print(f"{amount} TL yatırıldı. Yeni bakiye: {self.balance} TL")
else:
print("Geçersiz tutar.")
# Para çekme işlemi için metot
def money_check(self, amount):
if amount <= self.balance:
self.balance -= amount
print(f"{amount} TL çekildi. Kalan bakiye: {self.balance} TL")
else:
print("Yetersiz bakiye. İşlem iptal edildi.")
def display_balance(self):
print(f"Mevcut Bakiye: {self.balance} TL")
# Hem müşteri hem hesap bilgileri aynı anda giriliyor
account1 = Account(
name="Ahmet",
surname="Yılmaz",
tc_identification="12345678901",
phone="0555 123 45 67",
account_number="TR000100200300",
balance=0
)
# Müşteri bilgilerini yazdır
print("MÜŞTERİ BİLGİLERİ")
account1.display_information()
# Banka işlemleri
print("\nBANKA İŞLEMLERİ")
account1.display_balance()
account1.deposit(1000) # 1000 TL yatır
account1.money_check(400) # 400 TL çek
account1.money_check(800) # 800 TL çek (yetersiz)
account1.display_balance() # Bakiye görüntüle