Many personal computers, laptop computers, tablets, and smart phones have applications that allow a user to set reminder alarms. To accomplish this, all these applications use date and time functions that are built into the language they are programmed in.
Midterm project requirements:
In this project, you’ll create an alarm clock program that shows an announcement message at a user-inputted time and then draws an image of a clock face using the turtle module. You must incorporate the following:
- (20 points) The program shall ask the user for the time that the alarm should display the announcement message and the message that should be displayed.
- (20 points) The program shall use the datetime module for Python to get the current time.
- (10 points) The program shall monitor the time and display the message at the given time.
- (20 points) The program shall display a drawn clock face using the turtle module as part of the announcement that the alarm has finished. The clock face may display any time desired or simply be a drawn clock.
- (15 points) The program shall be commented to explain the programmer’s thought process.
- (15 points) The program shall be designed for usability, readability, and consistency.
Midterm project instructions:
This project will require you to integrate several of the concepts you’ve learned so far in this course. Taking a careful read of the instructions, let’s break down what should happen in this program.
- Ask the user for the time that the alarm should be displayed. Let’s think about how to do that. To make it easy using the datetime module, we should ask the user for the hour and the minute of the desired time separately. Then, we need to ask the user for the message that should be displayed when the alarm time is reached.
- Ask the user for the message that should be displayed when the alarm time is reached. Now we’re on to the tough part! How do we compare the time that the user gave us to the current time? That’s when you need to use the datetime module. We’re going to have to use two loops here: one when we check the hour and one when we check the minute, as well as some if statements!
- Check the current hour and see if it’s the same as the hour requested.
- If it’s the same, check the current minute and see if it’s the same as the minute requested.
- If it’s the same, display the message and draw the clock picture.
- If it’s not the same, continue checking the current minute until it is.
- If it’s not the same, continue checking the current hour until it is.
- If it’s the same, check the current minute and see if it’s the same as the minute requested.
Now that you’ve designed your program, let’s think about testing it. Since it will have to keep running until the alarm time is reached, try entering the time one or two minutes from now and letting it run to see if it works! You can design your clock face by itself and then add it to the appropriate part of the alarm once it’s working. That way, you don’t have to sit and wait for the right time to be reached each time you want to test your program!
My Answer
|
|