04 Teach : Team Activity
Objective
Demonstrate the use of multiple classes and files in Python.
Preparing for the Activity
Even though this assignment is available to everyone before the team activity, the expectation is that you do not work on it prior to your team meeting. Instead, you should prepare yourself by completing the assigned reading and at least Checkpoint A. Then, you meet and work through this assignment as a team.
Sometimes, students want to get ahead by doing this prior to the team meeting. Working beforehand on this assignment should be an exception, but may be the case if you feel you are struggling to understand some of the concepts as quickly as other teammates, and would like to better prepare yourself for the meeting. If you have done some of it beforehand, please make sure to patiently help everyone work through these components rather than presenting your code and asking them to accept it.
Special Instructions for Online Students
You need to coordinate a one hour synchronous team meeting for this activity.
Overview
Assume you have been asked to work on the I-Learn system. One of the components of that system is to handle assignments. Each assignment has three different dates: a start date, a due date, and an end date.
Your task is to write a Python class for an Assignment, and another for Date. (Please note that there is a built in class for "datetime" in Python, but we are practicing creating our own classes here, so we'll just use our simple one for this example and make it ourselves.)
In addition, you should put each of these classes in their own file, and then another file that contains a main function to test them. Thus, you should have 3 separate files.
Instructions
Class Specifications
The following UML class diagrams define your classes:
Date |
---|
day : int |
month : int |
year : int |
__init__() |
prompt() |
display() |
Assignment |
---|
name : string |
start_date : Date |
due_date : Date |
end_date : Date |
__init__() |
prompt() |
display() |
For the Date class:
Day, month, and year all store integer values.
The __init__ function should initialize the date to January 1, 2000
The prompt function should ask for a day, month, and year value.
The display function should display the date in the format "mm/dd/yyyy"
For the Assignment class:
Name holds a string, and the start, due, and end dates all hold Dates.
The __init__ function should initialize the name to "Untitled" and the dates to empty Date objects.
The prompt function should ask for a name, then each of the three dates in turn. (Don't forget to make use of the date class methods here.)
The display function should display the name and each of the dates (don't forget to make use of the date class methods here.)
Core Requirements
Create a Date class in a file date.py with the above variables and methods.
Create an Assignment class in a file assignment.py with the above variables and methods. Have it import the Date class from the date.py file.
Create a main function in a file main.py that creates a new Assignment, prompts for its values and display them. Have it import the Assignment class from the assignment.py file. Then, tar up your files and ensure that your solution passes testBed. (See the instructions for Check04B for more information.)
Sample Output
The following is an example of output for this program:
Name: Robot Project
Start Date:
Day: 4
Month: 10
Year: 2016
Due Date:
Day: 7
Month: 10
Year: 2016
End Date:
Day: 21
Month: 10
Year: 2016
Assignment: Robot Project
Start Date:
10/4/2016
Due Date:
10/7/2016
End Date:
10/21/2016
Running TestBed
Because TestBed only accepts a single file to run on, we need to tar up our files together and submit the resulting .tar file. See the instructions for Check04B for more information.
The following commands may come in handy:
tar -cf ta04.tar *.py
testBed cs241/ta04 ta04.tar
Notice that is NOT:
tar -cf *.py # This is BAD
Stretch Challenges
When you have completed the core requirements, and everyone on the team feels comfortable with them, please move on to these stretch challenges.
Detect if a user enters an invalid month (not 1-12) or a year before 2000 and reprompt them. (We won't worry about days at this point...)
Change the display function for dates so that months and days are always two digits (e.g. 01/02/2000 instead of 1/2/2000).
Create a display_long function for dates to display them in long format: January 01, 2000 (instead of 01/01/2000)
Instructor's Solution
As a part of this team activity, you are expected to look over a solution from the instructor, to compare your approach to that one. One of the questions on the I-Learn submission will ask you to provide insights from this comparison.
Please DO NOT open the solution until you have worked through this activity as a team for the one hour period. At the end of the hour, if you are still struggling with some of the core requirements, you are welcome to view the instructor's solution and use it to help you complete your own code. Even if you use the instructor's code to help you, you are welcome to report that you finished the core requirements, if you code them up yourself.
After working with your team for the one hour activity, click here for the instructor's solution.
Submission
When you have finished this activity, please fill out the assessment in I-Learn. You are welcome to complete any additional parts of this activity by yourself or with others after class before submitting the assessment.