Untitled

mail@pastecode.io avatar
unknown
plain_text
a month ago
8.8 kB
4
Indexable
Never
import datetime # ده اللي جبته علشان اعرف التاريخ اليوم
class TaskManager:
    def __init__(self, title, description, duedate, status,type,category):
        self._title = title
        self._description = description
        self._dueDate = duedate
        self._status = status
        self._type = type
        self._category =category
    def get_title(self):
        return self._title
    def set_title(self,x):
        self._title = x
        return self._title
    def get_description(self):
        return self._description
    def set_description(self,x):
        self._description = x
        return self._description
    def get_duedata(self):
        return self._dueDate
    def set_duedata(self,x):
        self._dueDate = x
        return self._dueDate
    def get_status(self):
        return self._status
    def set_status(self,x):
        self._status = x
        return self._status
    def get_type(self):
        return self._type
    def set_type(self,x):
        self._type = x
        return self._type
    def get_category(self):
        return self._category

#   حته list معرفها بدري شويه علشان احط فيها الابجكت
list_work =[]
list_presonal =[]
class presonal(TaskManager):

    def __int__(self, title,description,duedat,status,type,category):
        super().__init__(title, description, duedat, status, type)
        self.category = category




class Work(TaskManager):

    def __int__(self, title,description,duedat,status,type):


        super().__init__(title,description,duedat,status,type)

# بياخد القيم ويضفها و return
def add():
    title = input("enter the title:\n")
    description = input("enter the description\n")
    day =0
    month =0
    year = 0
    #لوب علشان يكرر بس ممكن تتحاش لما نجمع الكود
    while day == 0 and month == 0 and year == 0:
        duedat = (input("enter the duedat:\n"))
        dt = datetime.datetime.now()
        # هندلتها عشان لو دخل اسم في في التاريخ
        #خد التاريخ وفصلته وقارنته بتريخ اليوم علشان متحتش تاسك بتاريخ منتهي
        # اي قيمه عملها بصفر ده علشان يعيد الحته دي
        try:
            daye, monthe, yeare = duedat.split("-")
            day, month, year = int(daye), int(monthe), int(yeare)
            if year == dt.year:
                if month >= dt.month:
                    if day >= dt.day:
                        continue
                    else:
                        print("past history, try again")
                        day = 0
                        month = 0
                        year = 0
                else:
                    print("past history, try again")
                    day = 0
                    month = 0
                    year = 0
            elif year > dt.year:
                continue
            else:
                print("past history, try again")
            day = 0
            month = 0
            year = 0
        except ValueError:
            print("ValueError:")
    # عملتها كدي اختاصر كتابه لان ده طبيعي
    status ="incomplet"
    user_choice = input("enter yor number of choice to make type of task [1]work [2]personal\n")
    global list_presonal
    global list_work
    if user_choice == '1':
        type = 'work'
        list_work.append(Work(title, description, duedat, status, type,"no"))
    if user_choice == '2':
        c = input("enter category like  separated by space ('famliy sport')")
        category = c.split()
        print(category)
        type = 'personal'

        list_presonal.append(Work(title,description,duedat,status,type,category))
    ############################ خد بالك من دي
# دي كنت عاوز عملها ان هي تشوف التارخ خلصان او ترنب التاوريخ في list بس معرفتش
###########################
def due_time_end():
    pass

# دي بيحوش الابجكت من list

def delete(k):
    user_choice = input("enter number of choice to delete:[1]work task [2]perspnal task\n")
    try:
        if user_choice == '1':
            list_work.remove(list_work[k])
        if user_choice == '2':
            list_presonal.remove(list_presonal[k])
    except IndexError:
        print("key not found")
#دي بيعرض كل ابجكت من list

def show():
    user_choice=input("enter number of choice to show :[1]work task[2]personal task")
    if user_choice == '1':
        if list_work == []:
            print("empty")
        for k in list_work:
            print("-"*50)
            print(f"title : {k.get_title()}\ndescripion\n{k.get_description()}\ndue date : {k.get_duedata()}\nstatus : {k.get_status()}\nkey : {list_work.index(k)}")
    if user_choice == '2':
        if list_presonal == []:
            print("empty")
        for k in list_presonal:
            print("-"*50)
            print(f"title : {k.get_title()}\ncategory: {k.get_category()}\ndescripion\n{k.get_description()}\ndue date : {k.get_duedata()}\nstatus : {k.get_status()}\nkey : {list_presonal.index(k)}")
#بيعمل تحديس لل تاريخ يدوي
# تقربا كلها من add بسممكن نختصر كل ده ونعمل فنكشن تاني تعمل العمليه دي
def update():
        user_list_choice = input("enter number of choice [1] work task [2] personal task\n")
        key = int(input("enter the key to change\n"))
        user_choice =''
        user_choice =input("enter choice [1]due data [2]status\n")
        if user_choice == "1":
            day = 0
            month = 0
            year = 0
            while day == 0 and month == 0 and year == 0:
                duedat = (input("enter the duedat:\n"))
                dt = datetime.datetime.now()
                # هندلتها عشان لو دخل اسم في في التاريخ
                # خد التاريخ وفصلته وقارنته بتريخ اليوم علشان متحتش تاسك بتاريخ منتهي
                # اي قيمه عملها بصفر ده علشان يعيد الحته دي
                try:
                    daye, monthe, yeare = duedat.split("-")
                    day, month, year = int(daye), int(monthe), int(yeare)
                    if year == dt.year:
                        if month >= dt.month:
                            if day >= dt.day:
                                continue
                            else:
                                print("past history, try again")
                                day = 0
                                month = 0
                                year = 0
                        else:
                            print("past history, try again")
                            day = 0
                            month = 0
                            year = 0
                    elif year > dt.year:
                        continue
                    else:
                        print("past history, try again")
                    day = 0
                    month = 0
                    year = 0
                except ValueError:
                    print("ValueError:")
            try:
                if user_list_choice =="1":
                    list_work[key].set_duedata(duedat)
                elif user_list_choice =="2":
                    list_presonal[key].set_duedata(duedat)
            except IndexError:
                print("key not found")
        elif user_choice=="2":
            user_choice_c = input("enter choice:\n[1]complet [2] will complet\n")
            if user_list_choice == "1":
                if user_choice_c == "1":
                    list_work[key].set_status("complet")
                elif user_choice_c == '2':
                    list_work[key].set_status('will complet')
                else:
                    print('try again')
            if user_list_choice == "2":
                if user_choice_c == "1":
                    list_presonal[key].set_status("complet")
                elif user_choice_c == '2':
                    list_presonal[key].set_status('will complet')
                else:
                    print('try again')
# قائمه هتتغير لما هنركب الكود
user_in = 0
while user_in != 5:
    user_in = input("[1]add [2]delet [3]updet [4]show\n")
    if user_in == "1":
        add()
    elif user_in == "2":
        delete(int(input("enter key of task to delete\n")))
    elif user_in == "3":
        # ده علشان تتاكد انه شغال
        update()
    elif user_in == "4":
        # عرض التاسك
        show()
    elif user_in == "5":
        exit()
Leave a Comment