Class Time with properties : Class Definition : Class PYTHON examples


PYTHON examples » Class » Class Definition »

 

Class Time with properties


 

class Timeobject ):
   def __init__self, hourValue, minuteValue, secondValue ):
      self.__hour = hourValue
      self.__minute = minuteValue
      self.__second = secondValue

   def __str__self ):
      return "%.2d:%.2d:%.2d" self.__hour, self.__minute, self.__second 

   def deleteValueself ):
      raise TypeError, "Cannot delete attribute"

   def setHourself, value ):
      if <= value < 24:
         self.__hour = value
      else:
         raise ValueError, "hour (%d) must be in range 0-23, inclusive" % value

   def getHourself ):
      return self.__hour

   hour = propertygetHour, setHour, deleteValue, "hour" )   

   def setMinuteself, value ):
      if <= value < 60:
         self.__minute = value
      else:
         raise ValueError, "minute (%d) must be in range 0-59, inclusive" % value

   def getMinuteself ):
      return self.__minute       

   minute = propertygetMinute, setMinute, deleteValue, "minute" )

   def setSecondself, value ):
      if <= value < 60:
         self.__second = value
      else:
         raise ValueError, "second (%d) must be in range 0-59, inclusive" % value

   def getSecondself ):
      return self.__second

   second = propertygetSecond, setSecond, deleteValue, "second" )

   
  



Leave a Comment / Note


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


PYTHON examples

 Navioo Class
» Class Definition