-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPhone Book Project.txt
129 lines (117 loc) · 5.09 KB
/
Phone Book Project.txt
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
print()
print("*******************************************************************************")
print("* Abrar ul Hassan ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Muzammil *")
print("<-------------------------- WELCOME TO BUGA PHONEBOOK ------------------------>")
print("* 10970 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -------- *")
print("*******************************************************************************")
class Phone:
def __init__(self, PhoneData=None, next=None):
self.data = PhoneData
self.next = next
class PhoneBook:
def __init__(self):
self.head = None
def search_Phone_Data(self, Phone_Data):
if self.head is None:
print("--No Phone Book Data is Available--")
return
n = self.head
while n is not None:
if n.data == Phone_Data:
print(str(Phone_Data)+" is Available in Phone Book")
return True
n = n.next
print(" Sorry! Phone Data "+str(Phone_Data)+" is Not Available ")
return False
def Update_Phone_Data(self,old_Phone_Data,New_Phone_Data):
if self.head is None:
print("Sorry Books are Not Available")
return
if old_Phone_Data == New_Phone_Data:
print("Already! This Book iS Available ")
return
replace=self.head
while replace is not None:
if replace.data == old_Phone_Data:
replace.data = New_Phone_Data
print(str(replace.data)+" Updated Successfully ! THANK YOU ")
return
replace=replace.next
print("Books is Not Available")
def Phone_Data_Insert(self, Phone_Data):
newData = Phone(Phone_Data)
if (self.head):
current = self.head
while (current.next):
current = current.next
current.next = newData
else:
self.head = newData
def Display_Phone_Book(self):
current = self.head
while (current):
print(current.data)
current = current.next
Name=input("Hello : Welcome To Buga PhoneBook---What's Your Name : ")
userName=input("Mr "+str(Name)+" Please Provide User Name : ")
passwrad=input("Mr "+str(Name)+" Please Provide User Password : ")
if ((userName == "Abrar" or userName == "Abrar ul Hassan" or userName == "Muzammil" or userName == "muzammil Ansari") and passwrad
=="abrar36987" or userName == "Muzammil1234"):
print()
print("---Login SuccessFull---")
print()
LL = PhoneBook()
print("<---------------------------------->")
LL.Phone_Data_Insert("Abrar ul Hassan")
LL.Phone_Data_Insert("03032033694")
LL.Phone_Data_Insert("[email protected]")
LL.Phone_Data_Insert("Khalid Hussain")
LL.Phone_Data_Insert("03026798776")
LL.Phone_Data_Insert("[email protected]")
LL.Display_Phone_Book()
print("<---------------------------------->")
print()
while True:
print(" 1.Add Books ")
print(" 2.Visit the Whole Books ")
print(" 3.Update the Book ")
print(" 4.Search Book ")
choice = int(input("Enter your Choice Number : "))
if choice not in [1, 2, 3, 4]:
print("Please Enter the valid Option")
continue
else:
choice = int(choice)
if choice == 1:
name = input("Mr " + str(Name) + "--> Please Insert Name : ")
number = input("Mr * " + str(Name) + "--> Please Insert Phone Number : ")
email = input("Mr * " + str(Name) + "--> Please Insert Email : ")
LL.Phone_Data_Insert(name)
LL.Phone_Data_Insert(number)
LL.Phone_Data_Insert(email)
print("Name : "+str(name)+"\nPhone Number : "+str(number)+"\nEmail : "+str(email))
print("<----Stored In Phone Book Successfully---->")
print("<----------------Thank You---------------->")
elif choice == 2:
print("---------- DISPLAYING PHONE BOOK ----------")
LL.Display_Phone_Book()
elif choice == 3:
oldbook = input("Mr "+str(Name)+"-->Please Insert OLD : Name or Phone Number or Email : ")
newbook = input("Mr "+str(Name)+"-->Please Insert New : Name or Phone Number or Email : ")
LL.Update_Phone_Data(oldbook, newbook)
elif choice == 4:
find = input("Mr "+str(Name)+" Please Insert the Name or Phone Number or Email For searching : ")
LL.search_Phone_Data(find)
else:
print("----Not A valid option----")
print("\npress Q TO Exit the Program and C for to Continue.....")
choice2 = " "
while choice2 != "C" and choice2 != "Q":
choice2 = input()
if choice2 == "Q":
print("-----THANKS FOR VISITED BUGA PHONE BOOK------")
exit()
elif choice2 == "C":
continue
else:
print("<---- Incorrect Password or UserNAME ---->")