Created
March 5, 2025 08:51
-
-
Save ProfAndreaPollini/6eb0b7ad6fd9efcee3fb0ece51625c96 to your computer and use it in GitHub Desktop.
esercizio todolist c++
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* ESERCIZIO: TODOLIST | |
* | |
* creare un programma che consenta di gestire | |
* un elenco di cose da fare. ogni todo è | |
* formato da (titolo, descrizione, done) | |
* dove done indica se è già stato | |
* realizzato. | |
* | |
* il programma deve consentire di | |
* inserire un nuovo todo, segnare un todo | |
* come done, mostrare i todo fatti e | |
* quelli ancora da fare,eliminare un todo, | |
* salvare e caricare la todolist da un file(!) | |
* | |
*/ | |
// entità todo | |
#include <format> | |
#include <iostream> | |
#include <string> | |
#include <vector> | |
struct Todo { | |
std::string titolo; | |
std::string descrizione; | |
bool fatto; | |
}; | |
using TodoList = std::vector<Todo>; | |
int main() { | |
TodoList todolist; | |
Todo a; | |
//std::cout << std::format("inserisci {} sdf {} sdfd",2,3); | |
std::cout << "titolo> "; | |
std::getline(std::cin,a.titolo); | |
std::cout << "descrizione> "; | |
std::getline(std::cin,a.descrizione); | |
a.fatto = false; | |
// aggiungi alla lista | |
todolist.push_back(a); | |
// stampa lista todo | |
for (const auto&el: todolist) { | |
std::string done_str = " "; | |
if (el.fatto) { | |
done_str = "X"; | |
} | |
std::cout << | |
std::format("titolo: {}, descrizione: {} [{}]\n", | |
el.titolo,el.descrizione,done_str); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment