84 lines
2.2 KiB
Plaintext
84 lines
2.2 KiB
Plaintext
import psycopg2
|
|
import threading as th
|
|
conn = psycopg2.connect(database="dbad_s490103",
|
|
host="psql.wmi.amu.edu.pl",
|
|
user="dbad_s490103",
|
|
password="agiesticancoadi")
|
|
|
|
cursor = conn.cursor()
|
|
cursor.execute("select * from tresc") #programowanie deklaratywne
|
|
|
|
|
|
data = cursor.fetchall()[0]
|
|
|
|
conn.close()
|
|
|
|
sens_zdanie = lambda x: " ".join(x[:-1]) + x[-1] #funkcja lambda
|
|
|
|
lista = []
|
|
|
|
class zadanie: #programowanie obiektowe
|
|
def __init__(self, tresc):
|
|
self.tresc = tresc
|
|
|
|
program_on = True
|
|
|
|
def instrukcje(p):
|
|
print(sens_zdanie(p))
|
|
print('Aby usunąć zadanie, wpisz "usun". \nAby dodać zadanie, wpisz "dodaj". \nAby zakończyć działanie program, wpisz "stop"')
|
|
|
|
def ozdobniki():
|
|
print("="*46)
|
|
|
|
print()
|
|
if __name__ == "__main__": #multithreading
|
|
t1 = th.Thread(target=ozdobniki, args=())
|
|
t2 = th.Thread(target=instrukcje, args=(data,))
|
|
t3 = th.Thread(target=ozdobniki, args=())
|
|
|
|
t1.start()
|
|
t2.start()
|
|
t3.start()
|
|
|
|
t1.join()
|
|
t2.join()
|
|
t3.join()
|
|
|
|
|
|
while program_on:
|
|
print()
|
|
print("========= TWOJA LISTA =========")
|
|
for i in lista:
|
|
print(f'{i[0]}. {i[1].tresc}')
|
|
print()
|
|
wybor = input().lower()
|
|
match wybor:
|
|
case "dodaj":
|
|
tekst = input().strip()
|
|
zadanie_do_dodania = zadanie(tekst)
|
|
if len(lista) == 0:
|
|
lista.append([1, zadanie_do_dodania])
|
|
else:
|
|
lista.append([lista[-1][0]+1, zadanie_do_dodania])
|
|
|
|
case "usun":
|
|
numer = input()
|
|
try:
|
|
numer = int(numer)
|
|
if numer > len(lista):
|
|
print("Nie ma zadania o takim numerze!")
|
|
else:
|
|
lista.remove(lista[numer-1])
|
|
for i in range(numer-1, len(lista)):
|
|
lista[i][0]-=1
|
|
except:
|
|
print("Musisz wprowadzić numer.")
|
|
|
|
case "stop":
|
|
break
|
|
|
|
case _:
|
|
print("Wprowadź prawidłową komendę.")
|
|
|
|
|