diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json new file mode 100644 index 00000000..f9128470 --- /dev/null +++ b/.vscode/c_cpp_properties.json @@ -0,0 +1,18 @@ +{ + "configurations": [ + { + "name": "windows-gcc-x86", + "includePath": [ + "${workspaceFolder}/**" + ], + "compilerPath": "C:/MinGW/bin/gcc.exe", + "cStandard": "${default}", + "cppStandard": "${default}", + "intelliSenseMode": "windows-gcc-x86", + "compilerArgs": [ + "" + ] + } + ], + "version": 4 +} \ No newline at end of file diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 00000000..2f014ea6 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,24 @@ +{ + "version": "0.2.0", + "configurations": [ + { + "name": "C/C++ Runner: Debug Session", + "type": "cppdbg", + "request": "launch", + "args": [], + "stopAtEntry": false, + "externalConsole": true, + "cwd": ".", + "program": "build/Debug/outDebug", + "MIMode": "gdb", + "miDebuggerPath": "gdb", + "setupCommands": [ + { + "description": "Enable pretty-printing for gdb", + "text": "-enable-pretty-printing", + "ignoreFailures": true + } + ] + } + ] +} \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 00000000..c9e66f12 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,59 @@ +{ + "C_Cpp_Runner.cCompilerPath": "gcc", + "C_Cpp_Runner.cppCompilerPath": "g++", + "C_Cpp_Runner.debuggerPath": "gdb", + "C_Cpp_Runner.cStandard": "", + "C_Cpp_Runner.cppStandard": "", + "C_Cpp_Runner.msvcBatchPath": "C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Auxiliary/Build/vcvarsall.bat", + "C_Cpp_Runner.useMsvc": false, + "C_Cpp_Runner.warnings": [ + "-Wall", + "-Wextra", + "-Wpedantic", + "-Wshadow", + "-Wformat=2", + "-Wcast-align", + "-Wconversion", + "-Wsign-conversion", + "-Wnull-dereference" + ], + "C_Cpp_Runner.msvcWarnings": [ + "/W4", + "/permissive-", + "/w14242", + "/w14287", + "/w14296", + "/w14311", + "/w14826", + "/w44062", + "/w44242", + "/w14905", + "/w14906", + "/w14263", + "/w44265", + "/w14928" + ], + "C_Cpp_Runner.enableWarnings": true, + "C_Cpp_Runner.warningsAsError": false, + "C_Cpp_Runner.compilerArgs": [], + "C_Cpp_Runner.linkerArgs": [], + "C_Cpp_Runner.includePaths": [], + "C_Cpp_Runner.includeSearch": [ + "*", + "**/*" + ], + "C_Cpp_Runner.excludeSearch": [ + "**/build", + "**/build/**", + "**/.*", + "**/.*/**", + "**/.vscode", + "**/.vscode/**" + ], + "C_Cpp_Runner.useAddressSanitizer": false, + "C_Cpp_Runner.useUndefinedSanitizer": false, + "C_Cpp_Runner.useLeakSanitizer": false, + "C_Cpp_Runner.showCompilationTime": false, + "C_Cpp_Runner.useLinkTimeOptimization": false, + "C_Cpp_Runner.msvcSecureNoWarnings": false +} \ No newline at end of file diff --git "a/Intermediate Level \360\237\223\201/contacts/contacts.json" "b/Intermediate Level \360\237\223\201/contacts/contacts.json" new file mode 100644 index 00000000..e69de29b diff --git "a/Intermediate Level \360\237\223\201/contacts/contacts.py" "b/Intermediate Level \360\237\223\201/contacts/contacts.py" new file mode 100644 index 00000000..57224066 --- /dev/null +++ "b/Intermediate Level \360\237\223\201/contacts/contacts.py" @@ -0,0 +1,65 @@ +import json +import os + +CONTACTS_FILE = 'contacts.json' + +def load_contacts(): + """Charge les contacts depuis le fichier JSON.""" + if os.path.exists(CONTACTS_FILE): + with open(CONTACTS_FILE, 'r') as file: + return json.load(file) + return [] + +def save_contacts(contacts): + """Sauvegarde les contacts dans le fichier JSON.""" + with open(CONTACTS_FILE, 'w') as file: + json.dump(contacts, file, indent=4) + +def add_contact(name, phone): + """Ajoute un contact à la liste.""" + contacts = load_contacts() + contacts.append({"name": name, "phone": phone}) + save_contacts(contacts) + print(f"Contact ajouté : {name} - {phone}") + +def remove_contact(name): + """Supprime un contact de la liste.""" + contacts = load_contacts() + contacts = [c for c in contacts if c['name'] != name] + save_contacts(contacts) + print(f"Contact supprimé : {name}") + +def display_contacts(): + """Affiche tous les contacts.""" + contacts = load_contacts() + if not contacts: + print("Aucun contact trouvé.") + return + for c in contacts: + print(f"Nom : {c['name']}, Téléphone : {c['phone']}") + +def main(): + while True: + print("\nGestionnaire de Contacts") + print("1. Ajouter un contact") + print("2. Supprimer un contact") + print("3. Afficher tous les contacts") + print("4. Quitter") + + choice = input("Choisissez une option (1-4) : ") + if choice == '1': + name = input("Entrez le nom du contact : ") + phone = input("Entrez le numéro de téléphone : ") + add_contact(name, phone) + elif choice == '2': + name = input("Entrez le nom du contact à supprimer : ") + remove_contact(name) + elif choice == '3': + display_contacts() + elif choice == '4': + break + else: + print("Choix invalide, veuillez réessayer.") + +if __name__ == "__main__": + main()