-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathoops_project.py
More file actions
93 lines (77 loc) · 2.72 KB
/
oops_project.py
File metadata and controls
93 lines (77 loc) · 2.72 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
class chatbook:
__user_id = 1
def __init__(self):
self.id = chatbook.__user_id
chatbook.__user_id += 1
self.__name = "Default User"
self.username = ''
self.password = ''
self.loggedin = False
# self.menu()
@staticmethod
def get_id():
return chatbook.__user_id
@staticmethod
def set_id(val):
chatbook.__user_id = val
# getter and setter methods
def get_name(self):
return self.__name
def set_name(self, value):
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 login
3. Press 3 to write a post
4. Press 4 to message a friend
5. Press any other key to exit\n""")
if user_input == "1":
self.signup()
elif user_input == "2":
self.login()
elif user_input == "3":
self.my_post()
elif user_input == "4":
self.send_msg()
else:
exit()
def signup(self):
email = input("enter your email: ")
pwd = input("enter your password: ")
self.username = email
self.password = pwd
print("Sign up successful !!")
print("\n")
self.menu()
def login(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: ")
pwd = input("enter your password: ")
if self.username == uname and self.password == pwd:
print("Login successful !!")
self.loggedin = True
else:
print("invalid username or password !!")
print("\n")
self.menu()
def my_post(self):
if self.loggedin == True:
txt = input("enter your message to post: ")
print(f"following content has been posted: {txt}")
else:
print("you need to login first to post something !!")
print("\n")
self.menu()
def send_msg(self):
if self.loggedin == True:
txt = input("enter your message to send: ")
frnd = input("whom do you want to send this message to: ")
print(f"your message has been sent to {frnd}")
else:
print("you need to signin first to send a msg something !!")
print("\n")
self.menu()
# user1 = chatbook()