Advertisement
niamulhasan

class constructor updated

Jan 11th, 2019
2,251
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.82 KB | None | 0 0
  1. class User:
  2.     name = ''
  3.     email = ''
  4.     password = ''
  5.     login = False
  6.  
  7.     def __init__(self, name, email, password):
  8.         self.name = name
  9.         self.email = email
  10.         self.password = password
  11.  
  12.     def login(self):
  13.         email = raw_input("Enter email: ")
  14.         password = raw_input("Enter password: ")
  15.  
  16.         if email == self.email and password == self.password:
  17.             self.login = True
  18.             print("Login Successful!")
  19.         else:
  20.             print("Login Failed!")
  21.  
  22.     def logout(self):
  23.         self.login = False
  24.         print("Logged Out!")
  25.  
  26.     def isLoggedIn(self):
  27.         if self.login == True:
  28.             return True
  29.         else:
  30.             return False
  31.  
  32.     def profle(self):
  33.         if self.isLoggedIn():
  34.             print(self.name,"-",self.email)
  35.         else:
  36.             print("User is not Logged in!")
  37.  
  38.  
  39. user1 = User("Adam", "adam@testmail.com","12345")
  40.  
  41. user1.login()
  42. user1.profle()
  43.  
  44.  
  45. hello = input()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement