import random as r
class Fish:
def init(self):
self.x=r.randint(0,10)
self.y=r.randint(0,10)
def move(self):
self.x=self.x-1
print('我的位置是:',self.x,self.y)
class Goldfish(Fish):
pass
class Salmon(Fish):
pass
class Shark(Fish):
def int(self):
Fish.__init__(self)
self.hungry=True
def eat(self):
if self.hungry:
print('我好饿!')
self.hungry=False
else:
print('我吃饱啦!')
# -*- coding: UTF-8 -*-
import random as r
class Fish:
def __init__(self):
self.x=r.randint(0,10)
self.y=r.randint(0,10)
def move(self):
self.x=self.x-1
print('我的位置是:',self.x,self.y)
class Goldfish(Fish):
pass
class Salmon(Fish):
pass
class Shark(Fish):
def __init__(self):
Fish.__init__(self)
self.hungry=True
def eat(self):
if self.hungry:
print('我好饿!')
self.hungry=False
else:
print('我吃饱啦!')
s = Shark()
s.eat()
s.eat()
我好饿!
我吃饱啦!