-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNote.py
More file actions
99 lines (88 loc) · 3.24 KB
/
Note.py
File metadata and controls
99 lines (88 loc) · 3.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
# -*- coding: utf-8 -*-
# Python Project
# Python Notes Handler
# Saumya Gupta, DS
class Note:
"""
Represents a single note
Attributes
----------
ID : (int) Unique identification number of note
dateCreated : (datetime) Creation date of note
title : (str) Title of note
text : (str) Text/body of note
isCompleted : (bool) True if note is completed, otherwise False
dateCompleted : (datetime) Completion date of note
Methods
-------
update_title(new_title) : Updates title of note
update_text(new_text) : Updates text/body of note
change_completion_status() : Toggles completion status of note
mark_complete(dateCompleted) : Marks note complete
mark_incomplete() : Marks note incomplete
get_all_data() : Returns dictionary of notes data
"""
def __init__(self, ID, dateCreated, title, text, isCompleted, dateCompleted=None):
"""
Initializes note attributes
:param ID: (int) ID for note generated automatically using incremental counter
:param dateCreated: (datetime) Current timestamp
:param title: (str) Title input by user
:param text: (str) Text/body input by user
:param isCompleted: (bool) True if note marked completed by user, otherwise False
"""
self.ID = ID
self.dateCreated = dateCreated
self.title = title
self.text = text
self.isCompleted = isCompleted
self.dateCompleted = dateCompleted
def update_title(self, new_title):
"""
Updates title of note to 'new_title'
:param new_title: New title input by user
:return: None
"""
self.title = new_title
def update_text(self, new_text):
"""
Updates text of note to 'new_text'
:param new_text: New text input by user
:return: None
"""
self.text = new_text
def change_completion_status(self):
"""
Toggles completion status of note; True changes to False and vice versa
:return: None
"""
self.isCompleted = not self.isCompleted
def mark_complete(self, dateCompleted):
"""
Marks note complete; completion date is set to 'dateCompleted': sets 'isCompleted' to True
:param dateCompleted: Completion date entered by user or current timestamp
:return: None
"""
self.dateCompleted = dateCompleted
self.isCompleted = True
def mark_incomplete(self):
"""
Marks note incomplete; completion date is set to 'None': sets 'isCompleted' to False
:return: None
"""
self.dateCompleted = None
self.isCompleted = False
def get_all_data(self):
"""
Returns dictionary of notes data
:return: (dict) Dictionary consisting note's metadata
"""
return {
'Note ID': str(self.ID),
'Title': self.title,
'Text': self.text,
'Completed': 'Yes' if self.isCompleted else 'No',
'Creation Date': str(self.dateCreated),
'Completion Date': str(self.dateCompleted) if self.dateCompleted else None
}
# This is end of script.