Polymorphism : Class Inheritance : Class PYTHON examples


PYTHON examples » Class » Class Inheritance »

 

Polymorphism


 

def rotate_tirescar :
   for i in range(1, car.tire_count()) :
       print "Moving tire from " + str(i)
       car.set_tirei+)
   print "Moving tire from " + str(car.tire_count())
   car.set_tire)

class Car(object:
    def __init__(self:
        self.number_of_tires = 4

    def set_tireself, nPos :
        print "Setting tire into position: " + str(nPos )

    def tire_count(self:
        return self.number_of_tires
        
class Hybrid(Car:
    def __init__(self:
        self.number_of_tires = 3

c = Car()
rotate_tires(c)
h = Hybrid()
rotate_tires(h)

   
  



Leave a Comment / Note


 
Verification is used to prevent unwanted posts (spam). .


PYTHON examples

 Navioo Class
» Class Inheritance