当前位置:网站首页>把上一次作业第一部分,有参数的类,改成无参数方式呈现,功能不变。
把上一次作业第一部分,有参数的类,改成无参数方式呈现,功能不变。
2022-04-22 06:12:00 【欣慰的三叶草(● ̄(エ) ̄●)】
把上一次作业第一部分,有参数的类,改成无参数方式呈现,功能不变。
Role():
(,name,age,sex,hobby):
._name=name
._age=age
._sex=sex
.hobby=hobby
set_name(,name):
._name=name
get_name():
(._name) >= (._name) <= :
._name
:
set_age(,age):
._age=age
get_age():
._age>=._age<= :
(._age)
:
set_sex(,sex):
._sex=sex
get_sex():
._sex (,):
._sex
:
play():
(%(.get_name(),.get_age(),.get_sex(),.hobby))
aa=Role(,)
aa.get_age()
aa.get_sex()
aa.play()
class Role(object):
def __init__(self):
print()
def get(self, name, age, sex, hobby):
self._name = name
self._age = age
self._sex = sex
self.hobby = hobby
def set_name(self,name):
self._name=name
def get_name(self):
if len(self._name) >= 2 and len(self._name) <= 4:
return self._name
else:
return '名字不合规!'
def set_age(self,age):
self._age=age
def get_age(self):
if self._age>=0 and self._age<= 150:
return str(self._age)
else:
return '年龄异常!'
def set_sex(self,sex):
self._sex=sex
def get_sex(self):
if self._sex in ('男','女'):
return self._sex
else:
return '性别不合规!'
def play(self):
print('我叫{} ,今年{}岁了,性别{} ,我个人很{} 。'.format(self.get_name(),self.get_age(),
self.get_sex(),self.hobby))
aa=Role()
aa.get('曹有根', 21, '男', '喜欢看动漫')
aa.play()
版权声明
本文为[欣慰的三叶草(● ̄(エ) ̄●)]所创,转载请带上原文链接,感谢
https://blog.csdn.net/cygqtt/article/details/106492017
边栏推荐
- Alibaba cloud's deployment of rsshub stepping on the pit notes
- Quotient principle of modular division
- 软件工程导论第六版复习(笔记)
- .NET学习笔记----关于.NET Core那些事(3)【配置文件的读取、json文件的通用解析、读取静态文件】
- PowerJob 工作流
- paging
- Service configuration center of Nacos
- RSS pit entry Guide
- Alternative ps8625 | alternative ps8622 | design and development of cost-effective EDP to LVDS adapter board cs5211
- Introduction to IC Analog Layout - learning notes on layout Basics (4)
猜你喜欢

.NET学习笔记----关于.NET Core那些事(3)【配置文件的读取、json文件的通用解析、读取静态文件】

Nacos service provider registration

CLion和动态链接库

Nacos cluster configuration
![. net learning notes - about Net core (3) [reading configuration files, general parsing JSON files, reading static files]](/img/7d/b4ce2ba6d0896d443997615156ab08.png)
. net learning notes - about Net core (3) [reading configuration files, general parsing JSON files, reading static files]

RSS pit entry Guide

Matlab: female voice to male voice

Mcs-5 interrupt technology (Theory)

Can transparent recording cloud gateway enables construction machinery

Difference between analog IC design and digital IC design, including salary table
随机推荐
Quotient principle of modular division
Nacos之服务配置中心
什么是socket编程?
Experiment 4 cycle program design
ASP.NET日常开发随手记------发送邮件
Goodbye, postman. One thing to say: apifox is yyds
mysql的zip安装教程
Nacos持久化切换配置
Nacos cluster architecture
Noi / 1.5.25: finding special natural numbers
What knowledge and skills need to be added to IC design?
ParseException Unparseable date 时间转换异常
paging
What is the learning route of switching to digital IC Verification? Is there time to start turning now? 985 master's degree, second year of Graduate School of Electronics
Solution to the problem of Chinese garbled code in pyftpdlib
RSS pit entry Guide
Sad process from Fab factory to IC Verification
分布式任务调度与计算框架:PowerJob 高级特性-OpenAPI 04
Activity支持多窗口显示
微信支付 iframe子页面 无响应