zoukankan      html  css  js  c++  java
  • 编写类-用户类

    # Author Eric Zhao 
    # -*- coding:utf-8 -*-
    class User():
    '''
    用户类
    '''
    def __init__(self,first_name,last_name,username,email,location):
    '''
    初始化属性 first_name,last_name,username,email,location
    '''
    self.first_name = first_name.title()
    self.last_name = last_name.title()
    self.username = username
    self.email = email
    self.location = location.title()
    self.login_attempts = 0

    def describe_user(self):
    """用户信息摘要"""
    print(" "+ self.first_name+"·"+self.last_name)
    print("User Name is "+self.username)
    print("Email is "+self.email)
    print("Location is " + self.location)

    def greet_user(self):
    """问候用户方法"""
    print(" Hello " + self.username)

    def increment_login_attempts(self):
    """企图登录增量方法"""
    self.login_attempts += 1

    def reset_login_attempts(self):
    """重置企图登录增量方法"""
    self.login_attempts = 0

    eric_user = User('eric','li','eric·li','556677@163.com','Beijing')
    eric_user.describe_user()
    eric_user.greet_user()
    print(" Marking 3 login attempts...")
    eric_user.increment_login_attempts()
    eric_user.increment_login_attempts()
    eric_user.increment_login_attempts()
    print(" Login attempts: "+ str(eric_user.login_attempts))

    print("Resetting login attempts...")
    eric_user.reset_login_attempts()
    print(" Login attempts: "+ str(eric_user.login_attempts))



    lisa_user = User('lisa','gao','lisa·gao','887766@163.com','Beijing')
    lisa_user.describe_user()
    lisa_user.greet_user()a
  • 相关阅读:
    redis 持久化
    Hyper-V虚拟机Redhat添加网卡找不到网卡配置文件解决方法
    java 查看ssl log
    iptables配置https防火墙策略
    java 一致性哈希源码 转
    mysql主备配置方法
    hibernate 缓存配置
    Hibernate中文乱码
    HttpPost 中文编码问题 EntityBuilder
    apache 配置tomcat代理
  • 原文地址:https://www.cnblogs.com/abarcher/p/10917892.html
Copyright © 2011-2022 走看看