00001
00002
00003 #include <string>
00004 #include <iostream>
00005 #include "liste.h"
00006 #include "ui.h"
00007 using namespace std;
00008
00009
00010
00011
00012
00013 void uiStampaLinea(){
00014 cout << "--------------------"<< endl << endl;
00015 }
00016
00017 void uiStampaMenu(Lista* voci){
00018 for (int i = 0; i < voci->n; i++){
00019 char* s = (char*) listeLeggiElemento(voci, i);
00020 cout << (i + 1) << '-' << s << endl;
00021 }
00022 cout << endl;
00023 }
00024
00025 int uiChiediScelta(int sceltaMax){
00026 int result = -1;
00027
00028 cout << "Digita una scelta tra 1 e " << sceltaMax;
00029 cout << " e premi INVIO: " << endl;
00030 while (result <= 0 || result > sceltaMax){
00031 cin >> result;
00032 if (cin.fail()){
00033
00034
00035
00036 cin.clear();
00037 char ch;
00038 cin >> ch;
00039 }
00040 }
00041 return result;
00042 }
00043
00044 void uiChiediConferma(){
00045
00046
00047 char* tmp = new char[MAXCONSOLEINPUT];
00048 strncpy(tmp, "", MAXCONSOLEINPUT);
00049 cout << "Premi un tasto e batti INVIO..." << endl;
00050 while (strncmp(tmp, "\n", MAXCONSOLEINPUT) == 0 ||
00051 strncmp(tmp, "", MAXCONSOLEINPUT) == 0){
00052 cin.getline(tmp, MAXCONSOLEINPUT);
00053 }
00054 delete[] tmp;
00055 }
00056
00057 char* uiChiediStringa(){
00058 char* result = new char[MAXCONSOLEINPUT];
00059 strncpy(result, "", MAXCONSOLEINPUT);
00060 cout << "Immetti il dato e premi INVIO: " << endl;
00061 while (strncmp(result, "\n", MAXCONSOLEINPUT) == 0 ||
00062 strncmp(result, "", MAXCONSOLEINPUT) == 0){
00063 cin.getline(result, MAXCONSOLEINPUT);
00064 }
00065 return result;
00066 }
00067
00068 void uiStampaBanner(){
00069 char* s[13] =
00070
00071 {" _______ _ \
00072 ",
00073 "|__ __| (_) \
00074 ",
00075 " | | ___ _ __ _ __ _ ___ Tennis Tournament 1.\
00076 0 ",
00077 " | |/ _ \\ '_ \\| '_ \\| / __| Copyleft 2004-200\
00078 5 Gotto&Moio ",
00079 " | | __/ | | | | | | \\__ \\ \
00080 ",
00081 " |_|\\___|_| |_|_| |_|_|___/ \
00082 ",
00083 " ,-----. _______ \
00084 _ ",
00085 " /\\ /\\ |__ __| \
00086 | | ",
00087 " / \\ / \\ | | ___ _ _ _ __ _ __ __ _ _ __\
00088 ___ ___ _ __ | |_ ",
00089 " ( : : ) | |/ _ \\| | | | '__| '_ \\ / _` | '_ \
00090 ` _ \\ / _ \\ '_ \\| __| ",
00091 " \\ +-+ / | | (_) | |_| | | | | | | (_| | | | \
00092 | | | __/ | | | |_ ",
00093 " +-' `-+ |_|\\___/ \\__,_|_| |_| |_|\\__,_|_| \
00094 |_| |_|\\___|_| |_|\\__| ",
00095 " `-----'"};
00096
00097 for (int i =0; i<13; i++){
00098 cout<<s[i]<<endl;
00099 }
00100 cout<<endl;
00101 }