English subtitles

← Incorrect Input - Software Debugging

Get Embed Code
4 Languages

Showing Revision 3 created 05/24/2016 by Udacity Robot.

  1. Now, all of this is fine and works well.
  2. There's no bug in here, but there's nothing in there which prevents misuse of my class.
  3. For instance, nothing prevents me from entering numbers in here which make no sense at all.
  4. For instance, I could enter -1 as the hour or -2 as the minutes or -3 as the seconds.
  5. This is not a valid time or we would have to come up with
  6. entirely new definition of what the valid time is.
  7. However, we can still instantiate such an object and even printed out comes as -1, -2, -3.
  8. So here we're still talking three numbers, but since Python does not provide static checking of types,
  9. that is checking of types when the program is being compiled or rather executed,
  10. there's noting that prevents me from passing objects which have a completely different type.
  11. So I could pass a string in here for instance and then hours would be initialized with the string--
  12. this means that I would get a time object in here, which is entirely invalid.
  13. So my situation is--I'm passing some string here in the hours attribute.
  14. And now for a quiz, so if I do this, do I get an error when initializing the time object
  15. or when printing the time object or never.