会员可以在此提问,百战程序员老师有问必答
对大家有帮助的问答会被标记为“推荐”
看完课程过来浏览一下别人提的问题,会帮你学得更全面
截止目前,同学们一共提了 132597个问题
JAVA 全系列/第十八阶段:亿级高并发电商项目_架构/编码(旧)/电商:基于FastDFS+Nginx+Kinkeditor实现商品新增 24241楼

sec.rar

Internal Server Error

The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there is an error in the application.


Python 全系列/第八阶段:轻量级Web开发利器-Flask框架/Flask视图基础和URL 24244楼
JAVA 全系列/第二阶段:JAVA 基础深化和提高/容器(旧) 24246楼
JAVA 全系列/第三阶段:数据库编程/MySQL数据库 24249楼

import turtle
class MyRectangle:

    def __init__(self,width = 100,height = 100,x = 0,y =0): #实例属性
        self.width = width
        self.height = height
        self.x = x
        self.y = y

    def getArea(self):#算面积,实例方法
        return (self.width * self.height)

    def getPerimeter(self):#算周长,实例方法
        return ((self.width + self.height) *2)

    def draw(self):         #画图像方法
        turtle.penup()
        turtle.goto(self.x, self.y)
        turtle.pendown()
        turtle.forward(self.width)
        turtle.left(90)
        turtle.forward(self.height)
        turtle.left(90)
        turtle.forward(self.width)
        turtle.left(90)
        turtle.forward(self.height)
        turtle.done()


s = MyRectangle()
print(s.getPerimeter())
print(s.getArea())
s.draw()

s = MyRectangle(200,10000,10,1)
print(s.getPerimeter())
print(s.getArea())
s.draw()

输出结果(乌龟图没有截图):截屏2020-08-24 上午11.35.51.png

问题:老师你好!我想问一下为什么我的输出结果只有两个结果,但是我一共调用了四次方法,前两个默认的数值被运用了,但是后面重新传参数的却没有输出结果。我的想法是,后面传参的新数值会覆盖原来默认的数值再跑一次程序,但是没有。麻烦老师能为我解释一下,谢谢!!

Python 全系列/第一阶段:Python入门/面向对象 24251楼
JAVA 全系列/第三阶段:数据库编程/JDBC技术 24253楼

课程分类

百战程序员微信公众号

百战程序员微信小程序

©2014-2025百战汇智(北京)科技有限公司 All Rights Reserved 北京亦庄经济开发区科创十四街 赛蒂国际工业园
网站维护:百战汇智(北京)科技有限公司
京公网安备 11011402011233号    京ICP备18060230号-3    营业执照    经营许可证:京B2-20212637