Skip to content

Commit

Permalink
Create Mood_Journal.py
Browse files Browse the repository at this point in the history
  • Loading branch information
from13 authored Nov 8, 2024
1 parent 5934023 commit 1b08bc3
Showing 1 changed file with 75 additions and 0 deletions.
75 changes: 75 additions & 0 deletions Mood_Journal.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
import json
from datetime import datetime

# Class to handle the mood journal
class MoodJournal:
def __init__(self, filename="mood_journal.json"):
self.filename = filename
self.entries = self.load_entries()

def load_entries(self):
try:
with open(self.filename, "r") as file:
return json.load(file)
except FileNotFoundError:
return {}

def save_entries(self):
with open(self.filename, "w") as file:
json.dump(self.entries, file, indent=4)

def add_entry(self, date, mood, thoughts):
self.entries[date] = {"mood": mood, "thoughts": thoughts}
self.save_entries()

def view_entries(self):
for date, entry in self.entries.items():
print(f"Date: {date}")
print(f"Mood: {entry['mood']}")
print(f"Thoughts: {entry['thoughts']}")
print("\n")

# Class to handle the mindfulness tips
class MindfulnessTips:
def __init__(self):
self.tips = [
"Take a deep breath and count to five.",
"Focus on the sensations in your body.",
"Notice your surroundings without judgment.",
"Take a moment to express gratitude.",
"Practice mindful listening when talking to others."
]

def get_daily_tip(self):
return self.tips[datetime.now().day % len(self.tips)]

# Main function
def main():
journal = MoodJournal()
tips = MindfulnessTips()

while True:
print("1. Add Mood Entry")
print("2. View Mood Entries")
print("3. Get Daily Mindfulness Tip")
print("4. Exit")

choice = input("Enter your choice: ")
if choice == "1":
date = datetime.now().strftime("%Y-%m-%d")
mood = input("How are you feeling today? ")
thoughts = input("What's on your mind? ")
journal.add_entry(date, mood, thoughts)
print("Entry added successfully!")
elif choice == "2":
journal.view_entries()
elif choice == "3":
print("Today's Mindfulness Tip: ")
print(tips.get_daily_tip())
elif choice == "4":
break
else:
print("Invalid choice. Please try again.")

if __name__ == "__main__":
main()

0 comments on commit 1b08bc3

Please sign in to comment.