Зміст курсу
In-Depth Python OOP
In-Depth Python OOP
4. Polymorphism and Abstraction
Challenge: User Auth
Завдання
Let's improve your User
class!
- Create the class attribute
is_authenticated
in theUser
class. - Define the
login()
method that takes argumentsself
andtaken_password
. - The
login()
method should compare the user and taken passwords.
If the user password is equal to the taken password, theTrue
should be assigned to theis_authenticated
attribute.
If the user password is not equal to the taken password, the"Wrong password!"
should be written in the console. - Define the
logout()
methods. This method should assign theFalse
value to theis_authenticated
instance attribute.
Завдання
Let's improve your User
class!
- Create the class attribute
is_authenticated
in theUser
class. - Define the
login()
method that takes argumentsself
andtaken_password
. - The
login()
method should compare the user and taken passwords.
If the user password is equal to the taken password, theTrue
should be assigned to theis_authenticated
attribute.
If the user password is not equal to the taken password, the"Wrong password!"
should be written in the console. - Define the
logout()
methods. This method should assign theFalse
value to theis_authenticated
instance attribute.
Все було зрозуміло?
Challenge: User Auth
Завдання
Let's improve your User
class!
- Create the class attribute
is_authenticated
in theUser
class. - Define the
login()
method that takes argumentsself
andtaken_password
. - The
login()
method should compare the user and taken passwords.
If the user password is equal to the taken password, theTrue
should be assigned to theis_authenticated
attribute.
If the user password is not equal to the taken password, the"Wrong password!"
should be written in the console. - Define the
logout()
methods. This method should assign theFalse
value to theis_authenticated
instance attribute.
Завдання
Let's improve your User
class!
- Create the class attribute
is_authenticated
in theUser
class. - Define the
login()
method that takes argumentsself
andtaken_password
. - The
login()
method should compare the user and taken passwords.
If the user password is equal to the taken password, theTrue
should be assigned to theis_authenticated
attribute.
If the user password is not equal to the taken password, the"Wrong password!"
should be written in the console. - Define the
logout()
methods. This method should assign theFalse
value to theis_authenticated
instance attribute.
Все було зрозуміло?
Challenge: User Auth
Завдання
Let's improve your User
class!
- Create the class attribute
is_authenticated
in theUser
class. - Define the
login()
method that takes argumentsself
andtaken_password
. - The
login()
method should compare the user and taken passwords.
If the user password is equal to the taken password, theTrue
should be assigned to theis_authenticated
attribute.
If the user password is not equal to the taken password, the"Wrong password!"
should be written in the console. - Define the
logout()
methods. This method should assign theFalse
value to theis_authenticated
instance attribute.
Завдання
Let's improve your User
class!
- Create the class attribute
is_authenticated
in theUser
class. - Define the
login()
method that takes argumentsself
andtaken_password
. - The
login()
method should compare the user and taken passwords.
If the user password is equal to the taken password, theTrue
should be assigned to theis_authenticated
attribute.
If the user password is not equal to the taken password, the"Wrong password!"
should be written in the console. - Define the
logout()
methods. This method should assign theFalse
value to theis_authenticated
instance attribute.
Все було зрозуміло?
Завдання
Let's improve your User
class!
- Create the class attribute
is_authenticated
in theUser
class. - Define the
login()
method that takes argumentsself
andtaken_password
. - The
login()
method should compare the user and taken passwords.
If the user password is equal to the taken password, theTrue
should be assigned to theis_authenticated
attribute.
If the user password is not equal to the taken password, the"Wrong password!"
should be written in the console. - Define the
logout()
methods. This method should assign theFalse
value to theis_authenticated
instance attribute.