Write a class called Clock to conceivably be used for keeping track of time. Assume that this is a 24 hour clock, where the hour number ranges from 0 (which is midnight) to 23 (which is 11 pm), and the minutes range from 0 to 59. Include the following methods:
a constructor that initializes the time to 8:30 am.
setTime(hour, minute): sets the clock time to a particular value
getMinutesPastMidnight(): returns the number of minutes that have elapsed since midnight. For example, if the time is 1:03, the method should return 63.
copyTime(anotherClock): sets the time of this clock to be the time that anotherClock has, where anotherClock is another Clock object
You should have no print statements anywhere in your code.
Each of the two problems below is worth half of an “M” for purposes of grading.
Write a recursive function makeMessage(text,number) that takes two parameters: a string, and a positive integer. The function should return a string consisting of the original string concatenated together the number of times specified. For example, if you call makeMessage(`hi!',3), it should return the string 'hi!hi!hi!'. Your function should not print anything.
Write a recursive function changeLetter(word, letter, replacement). The function should return a new word that is identical to the original, but with all occurrences of letter changed to the word replacement. For example, changeLetter('abbbacbd', 'b', 'dog') should return 'adogdogdogacdogd'. (Your code should not use the Python built-in methods find, index, partition, split, or replace.)
Get Free Quote!
298 Experts Online