-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOOPS_Project.py
More file actions
99 lines (79 loc) · 2.9 KB
/
OOPS_Project.py
File metadata and controls
99 lines (79 loc) · 2.9 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
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
class chatbook:
__user_id = 0
def __init__(self):
self.__name = "Default name" #Hidden Attribute
# self.user_id = 0
# self.user_id += 1
self.id = chatbook.__user_id
chatbook.__user_id+= 1
self.username = ""
self.password = ""
self.loggedin = False
# self.menu()
@staticmethod
def get_id():
return chatbook.__user_id
@staticmethod
def set_id(value):
chatbook.__user_id = value
def get_name(self): #Getter
return self.__name
def set_name(self, value): #Setter
self.__name = value
def menu(self):
user_input = input("""Welcome to Chatbook !! How would you like to proceed?
1- Press 1 to signup
2- Press 2 to signin
3- Press 3 to write a post
4- Press 4 to message a friend
5- Press any other key to exit
-> """)
if user_input == "1":
self.signup()
elif user_input == "2":
self.signin()
elif user_input == "3":
self.my_post()
elif user_input == "4":
self.sendmsg()
else:
exit()
def signup(self):
email = input("Please enter your email here ->")
passw = input("Setup your password here ->")
self.username = email
self.password = passw
print("You have signed up successfully !!")
print("\n")
self.menu()
def signin(self):
if self.username == "" and self.password == "":
print("Please signup first by pressing 1 in the main menu")
else:
uname = input("Enter your email/username here ->")
psd = input("Enter your password here ->")
if self.username == uname and self.password == psd:
print("You have signed in successfully !!")
self.loggedin = True
else:
print("Please input correct credentials !!")
print("\n")
self.menu()
def my_post(self):
if self.loggedin == True:
txt = input("Enter your message here ->")
print(f"Following content has been posted -> {txt}")
else:
print("You need to signin first to post something...")
print("\n")
self.menu()
def sendmsg(self):
if self.loggedin ==True:
txt = input("Enter your message here ->")
frnd = input("Whom to send the msg? ->")
print(f"Your message has been sent to {frnd}")
else:
print("You need to signin first to send a message to your friend...")
print("\n")
self.menu()
#user1 = chatbook()