def main():
    n = Note('hello')
    print('Testing of class Note')
    print()
    print(type(n))
    print(dir(n))
    print(n.__str__())
    print(n.__init__)
    print(n.__dict__)
    print(n.tags)
    print(n.memo)
    print(n.creation_date)
    print(n.match('hello'))
    print(n.match('hi'))
    print(n.id)

    nb = Notebook()
    print('Testing of class Notebook')
    print()
    print(type(nb))
    print(dir(nb))
    print(nb.__str__())
    print(nb.__init__)
    print(nb.__dict__)
    print(nb.notes)
    print(nb.new_note('hi'))
Beispiel #2
0
 def test_create(self):
     """Note must have id, memo, tags (optional), creation date"""
     note = Note('any memo', tags='one two')
     self.assertIsNotNone(note.id)
     self.assertIsNotNone(note.memo)
     self.assertIsNotNone(note.tags)
     self.assertIsInstance(note.creation_date, datetime.datetime)
Beispiel #3
0
def note():
    """
    a function for testing class Note
    """
    note = Note("IT and BA", tags="Applied science")
    print(f"Cheking if note belongs to class Note using fuction " +
          f"isinstance: {isinstance(note, Note)}")
    print(
        f"Using built-in object method __dict__ get all atributes and their values of note object: {note.__dict__}"
    )
    print(f"Atributes of note object: {dir(note)}")
Beispiel #4
0
 def test_create_different(self):
     """Notes must have different ids and creation dates"""
     n1 = Note('first')
     n2 = Note('second')
     self.assertNotEqual(n1.id, n2.id)
     self.assertNotEqual(n1.creation_date, n2.creation_date)
Beispiel #5
0
from notebook import Notebook, Note
from menu import Menu

note = Note('I am Steve Jobs!', 'Steve Jobs')
notebook = Notebook()
print("Created note: 'I am Steve Jobs!'")
print("Created notebook.")

print("\nIs notebook an object?", isinstance(notebook, object))
print("Is note an object?", isinstance(note, object))
print("Is notebook.new_note('Elon Musk', 'Elon') an object?",
      isinstance(notebook.new_note('Elon Musk'), object))
print("Is notebook.search('Elon') an object?",
      isinstance(notebook.search('Elon'), object))
print("Is notebook.__init__() an object?",
      isinstance(notebook.__init__(), object))
print("Is notebook.__str__() a string?", isinstance(notebook.__str__(), str))
print("Is note.memo a string?", isinstance(note.memo, str))
print("Is notebook an object of class Notebook?",
      isinstance(notebook, Notebook))

print("\nIs the word 'Steve' in note?", note.match('I'))
print("Is the word 'love' in note?", note.match('love'))

print("\nAdding new notes to the notebook...")
notebook.new_note('You are not Steve Jobs!', 'answer 1')
notebook.new_note('I am.', 'answer 2')
for note in notebook.notes:
    print('Memo: {}, Tag: {}.'.format(note.memo, note.tags))

print("\nModifying memo of the first note:")
Beispiel #6
0
from notebook import Note

n1 = Note("Hello first")
n2 = Note("Hello", 'tag1 teg2')

print(n1.id, n2.id)
print(n1.match('Hello'), n2.match('he'))

from notebook import Notebook
n = Notebook()
n.new_note('Hello', 'first note in the note book')
n.new_note('See you')
print(n.notes)
for note in n.notes:
    print(note.id)
n.modify_tags(4, 'checked')
n.modify_memo(3, "Hello again!")
print(n.notes[0].memo, ';', n.notes[1].tags)
print(n.search('you'), n.search('You'))
Beispiel #7
0
from notebook import Notebook, Note
from menu import Menu

# Exploring Note
print("Let's explore Note: \n")
note = Note("It's a new notebook.")
print('memo: ', note.memo)
print('memo type: ', type(note.memo))
print('id: ', note.id)
print('id type: ', type(note.id))
print('creation date: ', note.creation_date)
print('creation date type: ', type(note.creation_date), '\n')

print('Exploring some class methods: ')
print("method match: ")
print(note.match('new'))
print(note.match('hello'))

print('\nAll attributes of class Note: ')
print(dir(Note))

print("\nDocumentation of note: ")
print(note.__doc__)

print("Type of note: ")
print(type(note))

print("\nWhether note is object: ")
print(isinstance(note, object))

print("\nWhether note is Note: ")
Beispiel #8
0
from notebook import Note, Notebook
from menu import Menu

n1 = Note("hello first")
n2 = Note("hello again")
print(n1.id)
print(n2.id)
n1.match('hello')
n2.match('second')

notb = Notebook()
notb.new_note("hello world")
notb.new_note("hello again")
print(notb.notes)

print(notb.notes[0].id)
print(notb.notes[1].id)

notb.notes[0]
notb.search("hello")
notb.search("world")

notb.modify_memo(1, "hi world")
print(notb.notes[0].memo)

print(dir(notb))
print(dir(n2))

print(isinstance(n1, Note))
print(isinstance(notb, Notebook))
Beispiel #9
0
 def add_note(self):
     tag = input("Tag notatki: ")
     text = input("Tekst notatki: ")
     new_note = Note(text, tag)
     self.notebook.new_note(new_note)
Beispiel #10
0
def test_search_succeeds_when_filter_term_in_memo():
    note = Note("hello first")
    assert note.match("hello") == True
Beispiel #11
0
def test_note_creation_generates_unique_ids():
    note1 = Note("hello first")
    note2 = Note("hello again")
    assert note1.id != note2.id
Beispiel #12
0
def test_search_fails_when_filter_term_not_in_memo():
    note = Note("hello again")
    assert note.match("second") == False
Beispiel #13
0
from notebook import Note
from notebook import NoteBook


sentence1 = "hi"
note1 = Note(sentence1)

sentence1 = "hello"
note2 = Note(sentence1)

sentenct1 = "how are you?"
note3 = Note(sentence1)

print(note1)
note1.remove()
print(note1)

sentence2 = NoteBook("대화")
sentence2.add_note(note1)
sentence2.add_note(note2)
print(sentence2.get_number_of_pages())

sentence2.add_note(note1, 100)
for i in range(300):
    sentence2.add_note(note1, i)

print(sentence2.get_number_of_pages())
Beispiel #14
0
from notebook import Note
from notebook import NoteBook

good_sentence = """세상사는 데 도움이 되는 명언, 힘이 되는 명언, 용기를 주는 명언, 위로가 되는 명언, 좋은 명언 모음 100가지. 자주 보면 좋을 것 같아서 선별했습니다."""
note_1 = Note(good_sentence)

print(note_1)
note_1.remove()
print(note_1)

good_sentence = """삶이 있는 한 희망은 있다. - 키케로 """
note_2 = Note(good_sentence)

good_sentence = """하루에 3시간을 걸으면 7년 후에 지구를 한 바퀴 돌 수 있다. - 사무엘 존슨"""
note_3 = Note(good_sentence)

good_sentence = """행복의 문이 하나 닫히면 다른 문이 열린다. 그러나 우리는 종종 닫힌 문을 멍하니 바라보다가 우리를 향해 열린 문을 보지 못하게 된다. - 헬렌 켈러"""
note_4 = Note(good_sentence)

wise_saying_notebook = NoteBook("명언 노트")
wise_saying_notebook.add_note(note_1)
print(wise_saying_notebook.get_number_of_all_pages())

wise_saying_notebook.add_note(note_2)
print(wise_saying_notebook.get_number_of_all_pages())

wise_saying_notebook.add_note(note_3)
wise_saying_notebook.add_note(note_4)
print(wise_saying_notebook.get_number_of_all_pages())
print(wise_saying_notebook.get_number_of_all_characters())
Beispiel #15
0
 def test_match(self):
     """Note must match string present in its memo and tags"""
     n1 = Note('first note', 'one')
     self.assertTrue(n1.match('first'))
     self.assertTrue(n1.match('note'))
     self.assertTrue(n1.match('one'))
Beispiel #16
0
 def test_match_bad(self):
     """Must not match when filter is not present in memo or tags"""
     n1 = Note('first note', 'one')
     self.assertFalse(n1.match('second'))
     self.assertFalse(n1.match('two'))
     self.assertFalse(n1.match('notebook'))
from menu import Menu
from notebook import Note, Notebook

print(
    '##########################################################################'
)
note1 = Note('first note')

print('note1.memo:', note1.memo)
print(f'note1.match("first"): {note1.match("first")}')
print()
note2 = Note('second note', tags='2nd')
print('note2.memo:', note2.memo)
print('note2.tags:', note2.tags)
print(f'note2.match("2"): {note2.match("2")}')
print()
print()
print('isinstance(note1, Note): ', isinstance(note1, Note))
print('isinstance(note1, object): ', isinstance(note1, object))
print('isinstance(note1.id, int): ', isinstance(note1.id, int))
print('isinstance(note1.memo, str): ', isinstance(note1.memo, str))
print('dir(note1.id): ')
print()
print(dir(note1.id))
print()
print(
    '##########################################################################'
)
print()
notebook1 = Notebook()
notebook1.new_note('1st note in notebook1', tags='1st')
Beispiel #18
0
from notebook import NoteBook
from notebook import Note

quote_book = NoteBook("The Quote Book")

new_note = Note()
new_note.write_content(
    "Don't cry because it's over smile because it happened. -Dr.Seuss")

quote_book.add_note(new_note)

print(quote_book.get_number_of_pages())

quote_book.add_note(Note("Hello, World1"))
quote_book.add_note(Note("Hello, World2"))
quote_book.add_note(Note("Hello, World3"))
quote_book.add_note(Note("Hello, World4"))
quote_book.add_note(Note("Hello, World5"))

print(quote_book.get_number_of_pages())

my_note = quote_book.remove_note(1)
print(my_note)

print(quote_book.get_number_of_pages())
Beispiel #19
0
from notebook import Note, Notebook
from menu import Menu

menu = Menu()
print('Exploring menu:')
print('Menu attributes:')
print(dir(menu))

print()
print('Exploring classes Notebook and Note:')
print('Note1: Hello it is me!!!')
print('Note2: Here me again.')
print('Note3: Hello everyone in the world.')

notee = Note('Hello it is me!!!', 'me')
noteee = Note('Here me again', 'hi!')
note = Note('Hello everyone in the world.', 'world')
notebook = Notebook()

print(
    'Type of the note, the dictionary of first note, first note attributes: ')
print(type(notee))
print(notee.__dict__)
print(dir(notee))
note_match = notee.match('my note')
note_match2 = notee.match('Hello')
print('first note match function result(word: my note):', note_match)
print('first note match function result(word: Hello): ', note_match2)

notebook.new_note(notee.memo, notee.tags)  #сreating a new note
notebook.new_note(noteee.memo, noteee.tags)
Beispiel #20
0
def train():
    trial_sample = Note("The tester string")
    possible = ['', "object", "atributes", "self", "__init__", "__str__"]

    def show(item):
        result = []
        for i in range(30):
            result.append("\n")
            i + 2

        result.append(
            f"This is the result of type({item}) in the instance of class Notef"
        )
        if possible.index(item) == 1:
            result.append(type(object))
        elif possible.index(item) == 2:
            result.append(type(trial_sample.memo))
        elif possible.index(item) == 3:
            result.append(type(trial_sample))
        elif possible.index(item) == 4:
            result.append(type(trial_sample.__init__))
        elif possible.index(item) == 5:
            result.append(type(trial_sample.__str__))
        result.append("\n")
        result.append(
            f"This are methods of {item} in the instance of class Note")

        if possible.index(item) == 1:
            for item in dir(object):
                result.append(item)
        elif possible.index(item) == 2:
            for item in dir(trial_sample.memo):
                result.append(item)
        elif possible.index(item) == 3:
            for item in dir(trial_sample):
                result.append(item)
        elif possible.index(item) == 4:
            for item in dir(trial_sample.__init__):
                result.append(item)
        elif possible.index(item) == 5:
            for item in dir(trial_sample.__str__):
                result.append(item)
        return result

    what_to_do = {}
    what_to_do["1"] = show(possible[1])
    what_to_do["2"] = show(possible[2])
    what_to_do["3"] = show(possible[3])
    what_to_do["4"] = show(possible[4])
    what_to_do["5"] = show(possible[5])

    message = "\n"+"1"+" "+"What is object "+\
                    "\n"+"2"+" "+"What is class atributes "+\
                    "\n"+"3"+" "+"That is self "+\
                    "\n"+"4"+" "+"What is __init__"+\
                    "\n"+"5"+" "+"What is __str__"+\
                    "\n\n"

    while True:
        print()
        print("What exactry do you want to know about OOP?")
        print("P.S type 'q' or Enter to quit ")
        print("Choose from these:")
        print()
        answer = input(message)

        if answer.lower() == "q" or answer == '':
            break
        while answer != 'q' and answer != '' and int(answer) not in range(
                1, 6):
            print("\n" * 50)
            print("This is incorrect option")
            print("Please try again")
            print("Chose from these:")
            print()
            answer = input(message)

        if answer.lower() == "q" or answer == '':
            break

        for item in what_to_do[answer]:
            print(item)
        print()
Beispiel #21
0
class Note:
    '''Represent a note in the notebook. Match against a string in searches and store tags for each note.'''
    def __init__(self, memo, tags=''):
        '''initialize a note with memo and optional space-separated tags.
        Automatically set the note's creation date and a unique id.'''
        self.memo = memo
        self.tags = tags
        self.creation_date = datetime.date.today()
        global last_id
        last_id += 1
        self.id = last_id

    def match(self, filter):
        '''Determine if this note matches the filter text.
        Return True if it matches, False otherwise.

        Search is case sensitive and matches both text and tags.'''
        return filter in self.memo or filter in self.tags


from notebook import Note

n1 = Note("hello first")
n2 = Note("hello again")

print(n1.id)
print(n1.match('hello'))
print(n2.id)
print(n2.match('again'))
# print(n1.match('wow'))
Beispiel #22
0
from notebook import Note, Notebook

if __name__ == "__main__":
    note1 = Note("My first note")
    print('Id of note1:', note1.id)
    note2 = Note("My second first note")
    print('Id of note2:', note2.id)
    print(note2.match('second'))

    print('\nIs n1 type - object?')
    print(isinstance(note1, object),'\n')

    print('\nThe contents of object note1:\n',dir(note1))
    print('\nThe contents of class Note:\n',dir(Note))

    print('\nType of note1.__init__(''):',type(note1.__init__('NoneType')))
    print('The contents of note1.__init__(''):\n',dir(note1.__init__('')))

    print('\nIs type of note1.memo: str?')
    print(isinstance(note1.memo, str))
    print('\nType of note1.creation_date')
    print(type(note1.creation_date))

    note1.type_self()

    print('\nType of note1.__str__')
    print(type(note1.__str__))
    print('Dir of note1.__str___')
    print(dir(note1.__str__))

    n = Notebook()
Beispiel #23
0
# class 활용 예제
from notebook import NoteBook
from notebook import Note

new_note = Note()
new_note.write_content("Don't cry. because I'm happy")

quote_book = NoteBook("The Quote Book")
quote_book.add_note(new_note)
quote_book.add_note(new_note)
quote_book.add_note(new_note)
quote_book.add_note(new_note)
quote_book.add_note(new_note)

print(quote_book.get_number_of_pages())

# quote_book.add_note(Note("Hellow, world"))
# quote_book.add_note(Note("Hellow, world"))
# quote_book.add_note(Note("Hellow, world"))

# print(quote_book.get_number_of_pages())

my_note = quote_book.remove_note(10)
print(my_note)
# my_note = quote_book.remove_note(1)
# print(my_note)
Beispiel #24
0
 def new_note(self, memo, tags=''):
     '''Create a new note and add it to the list.'''
     self.notes.append(Note(memo, tags))
Beispiel #25
0
 def new_note(self, memo, tags=''):
     self.notes.append(Note(memo, tags))
Beispiel #26
0
import sys
from notebook import Notebook, Note
from menu import Menu

if __name__ == "__main__":

    print('___' * 30)

    n1 = Note("hello first")
    n2 = Note("hello again")
    print('\nClass Note')
    print('ID of the first note:', n1.id)  # 1
    print('ID of the second note:', n2.id)  # 2
    print('Function match, the first note:', n1.match('hello'))  # True
    print('Function match, the second note:', n2.match('second'))  # False
    print('\ndir, class Note:', dir(Note))
    print('\ndir, the first note:', dir(n1))
    print("\ndir, n1.match", dir(n1.match))
    print('\nn1 is Note:', isinstance(n1, Note))
    print('n1 is object:', isinstance(n1, object))
    print('type of n1.id:', type(n1.id))
    print('type of n1.tags:', type(n1.tags))
    print('type of n1.creation_date:', type(n1.creation_date))
    print('\ndict of n1:', n1.__dict__)

    print('___' * 30)

    n = Notebook()
    n.new_note("hello world")
    n.new_note("hello again")
    print('\nClass Notebook')
Beispiel #27
0
from notebook import Note
n1 = Note("hello first")
print(n1.id)