Changes

Jump to: navigation, search

OPS435 Python3 Assignment 2P

201 bytes added, 19:02, 11 November 2019
Programmer-defined object type: Date
[[Category:OPS435-Python]][[Category:rchan]]
= Overview =
You have successfully design designed an algorithm to compute the date which is '''n''' day before or after a given date. You have also successfully implement implemented your algorithm using the Python language by identify identifying the functions that are need needed to perform the computation.
In this assignment, you are going to re-implement the algorithm you have for assignment 1 using python class. You are going to create a new programmer-define object call called Date with the appropriate data attributes and function attributes to support the necessary manipulation of '''date ''' object needed to implement your algorithm for assignment 1.
Your python script must follow the following coding guide:
** __init__(self): Date object constructor
** __repr__(self): return date object as a string in "yyyy-mm-dd" format
** __str__(self): return date object as a string in "yyyy:/mm:/dd" format
* Supporting function:
** days_to_time(): convert an integer which is n days from epoch (Jan 1, 1970) to a corresponding date object.
== Tests and Test results ==
You must name your class definition python script for Date as <code>a2_class.py</code>. The following test scripts tests in an interactive python sessions are for testing your class definition. The assignment test scripts can script called "checkA2P.py" should be used to test the date objects created by using once your Date classpasses all the interactive tests.
Please review those tests that failed and try to fix it in your class definition to address any bugs you may have.
=== Test for operator overloading '+' and '-' ===
: <source lang="python">
>>> d1
2019-11-07
 
>>> d2
2019-11-14
 
>>> d1 - d2
-7
 
>>> d2 - d1
7
 
>>> d2 = Date(2019,2,28)
>>> d2
2019-02-28
| class block || 5 ||
|-
| __init__() method || 10 5 ||
|-
| __str__() method || 5 ||
|-
| yesterday() method || 10 ||
|-
| day_of_week() function || 5||
|-
| docstring ||15||
1,760
edits

Navigation menu