1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112
| using System;
namespace ConsoleApp1
{
class Program
{
static void Main(string[] args)
{
string[,] tableauConservateur = new string[40, 3];
string[,] tableauArtiste = new string[40, 3];
string[,] tableauOeuvre = new string[40, 7];
menu();
string choix = Console.ReadLine();
int xChoix = Int32.Parse(choix);
switch(xChoix)
{
case 1:
AjoutConservateur();
break;
case 2:
AfficheConservateur();
break;
/*case 3:
AjoutOeuvre();
break;
case 4:
AffciheConservateur();
break;*/
}
}
private static void menu()
{
Console.WriteLine("================================================================");
Console.WriteLine("=======================Menu Principal===========================");
Console.WriteLine("================================================================");
Console.WriteLine("1. Ajout d'un conservateur");
Console.WriteLine("2. Ajout d'un artiste");
Console.WriteLine("3. Ajout d'un oeuvre");
Console.WriteLine("4. Afficher les conservateurs");
Console.WriteLine("5. Afficher les artistes");
Console.WriteLine("6. Afficher les oeuvres");
Console.WriteLine("7. Quitter");
Console.WriteLine("================================================================");
Console.WriteLine("Quel est votre choix ? ");
//Console.ReadLine();
}
public static void AjoutConservateur()
{
Console.Write("Code du conservateur: ");
string codeConservateur = Console.ReadLine();
if (codeConservateur.Length != 5)
{
Console.WriteLine("Le code doit avoir 5 caractères");
//doit ajouter retour au menu principal
}
int cnt = 0;
do
{
if (tableauConservateur[cnt, 0] == null)
{
break;
}
if (tableauConservateur[cnt, 0] == codeConservateur)
{
Console.WriteLine("Le code existe déjà");
//retour au module principale
}
cnt += cnt;
} while (cnt < 40);
tableauConservateur[cnt, 0] = codeConservateur;
Console.Write("Nom du conservateur: ");
string nomConservateur = Console.ReadLine();
if (nomConservateur.Length > 30)
{
Console.WriteLine("Le nom doit contenir moins de 30 caractères");
//retour au module appelant
}
tableauConservateur[cnt, 1] = nomConservateur;
tableauConservateur[cnt, 2] = "0";
}
public static void AfficheConservateur()
{
for (int cnt = 0; cnt < 41; cnt++)
{
//affiche tous les conservateurs du tableau
Console.WriteLine("Code Nom du conservateur");
Console.WriteLine(tableauConservateur[cnt, 0] + tableauConservateur[cnt, 1]);
}
}
}
} |
Partager