不懂为啥报错了。。请教下dalao。。

  1. 10月前
    10月前京斯 重新编辑
    class turtle:
        vitality = 100
        coordinate = [ ]
        def set_coordinate( self, initial_coordinate):#游戏开始随机生成乌龟的坐标
            self.initial_coordinate = initial_coordinate
            self.coordinate += self.initial_coordinate
        def move_coordinate( self, direction, distance):
    #direction决定x, y轴(0, 1)。distance决定移动的数值
            self.direction = direction
            self.distance = distance
            self.coordinate[self.direction] += self.distance
            self.vitality -= 1
    class fish:
        coordinate = [ ]
        def set_coordinate( self, initial_coordinate):
            self.initial_coordinate = initial_coordinate
            self.coordinate += self.initial_coordinate
        def move_coordinate( self, direction, distance):
    #direction决定x, y轴(0, 1)。distance决定移动的数值
            self.direction = direction
            self.distance = distance
            self.coordinate[self.direction] += self.distance
    import random
    #乌龟
    initial_turtle = [ random.randint( 0, 10), random.randint( 0, 10)]
    direction_turtle = random.randint( 0, 1)
    distance_turtle = random.choice( [ -1, 1, -2, 2])
    t = turtle
    t.set_coordinate( initial_turtle)
    t.move_coordinate( direction_turtle, distance_turtle)
    #鱼
    initial_fish = [ random.randint( 0, 10), random.randint( 0, 10)]
    direction_fish = random.randint( 0, 1)
    distance_fish = random.choice( [ -1, 1, -2, 2])
    f = fish
    f.set_coordinate( initial_turtle)
    f.move_coordinate( direction_fish, distance_fish)
  2. /data/user/0/com.hipipal.qpy3/files/bin/qpython-android5.sh "/storage/emulated/0/qpython/.last_tmp.py" && exit
    lated/0/qpython/.last_tmp.py" && exit <
    Traceback (most recent call last):
      File "/storage/emulated/0/qpython/.last_tmp.py", line 29, in <module>
        t.set_coordinate( initial_turtle)
    TypeError: set_coordinate() takes exactly 2 arguments (1 given)
    1|[email protected]:/ $

  3. 这是报错类型

  4. 京斯

    4楼 2018年4月4日 管理员
    10月前京斯 重新编辑

    大概要改成 t = turtle()f = fish()

  5. @京斯 大概要改成 t = turtle()f = fish()

    哇哇哇!!爱你啊!我宛如一个zz😂忘了加()。。。。

 

后才能发言