예제 #1
0
 static void AjouterPersonne(Personne p)
 {
     personnes.Add(p);
 }
예제 #2
0
        static void Main(string[] args)
        {
            // Seance march 23rd

            //File handling

            string     fileName = "test1.txt";
            FileStream fs       = new FileStream(fileName, FileMode.OpenOrCreate);

            Console.WriteLine($"file {fs.Name} was created successfully");

            StreamWriter sw = new StreamWriter(fs); // Write to the file

            sw.WriteLine("Hellooooooooooooooooooo");

            StreamReader sr = new StreamReader(fs); // Reads from the file

            while (sr.Peek() != -1)
            {
                Console.WriteLine(sr.ReadLine());
            }

            fs.Close(); // always close the stream when you are done with it

            // Exercice d'application

            Console.WriteLine("\n---------------------------------------------------------------\n");

            //test of Personne classe

            Personne p1 = new Personne("Kamal", "Mohammed");
            Personne p2 = new Personne("Lahlou", "Samir");
            Personne p3 = new Personne("Holmes", "Sherlcok");

            AjouterPersonne(p1);
            AjouterPersonne(p2);
            AjouterPersonne(p3);

            AjouterFichier();

            string path = Path.Combine(Environment.CurrentDirectory, "some.txt"); // get a path of a file

            var p = @"c:\\d.txt";                                                 // var modifier to assign default type to variable

            Console.WriteLine("\n---------------------------------------------------------------\n");

            // test of class Abonne, Repertoire
            Console.WriteLine("# TP-8 (suite) #\n");

            Console.WriteLine("Donnez le nombre d'abonnes par repertoire :");
            Console.Write("Nombre ::> ");

            int cap = int.Parse(Console.ReadLine());

            r = new Repertoire(cap);

            showMenu();
            MenuChoice menuChoice = GetChoice();

            while (menuChoice != MenuChoice.Quit)
            {
                switch (menuChoice)
                {
                case MenuChoice.AddAbonne:
                    AddAbonne();
                    break;

                case MenuChoice.ListAllAbonnes:
                    ListAllAbonnes();
                    break;

                case MenuChoice.SearchAbonneByName:
                    SearchAbonneByName();
                    break;

                case MenuChoice.SearchAbonneByPhoneNumber:
                    SearchAbonneByPhoneNumber();
                    break;

                case MenuChoice.ModifyPhoneNumberOfAbonne:
                    ModifyPhoneNumberOfAbonne();
                    break;

                case MenuChoice.DeleteAbonne:
                    DeleteAbonne();
                    break;

                case MenuChoice.SortAbonnes:
                    SortAbonnes();
                    break;

                case MenuChoice.SaveAbonnesToFile:
                    SaveAbonnesToFile();
                    break;

                case MenuChoice.ListAllAbonnesFromFile:
                    ListAllAbonnesFromFile();
                    break;

                case MenuChoice.SerializeAbonne:
                    SerializeAbonne();
                    break;

                case MenuChoice.DeserializeAbonne:
                    DeserializeAbonne();
                    break;
                }

                showMenu();
                menuChoice = GetChoice();
            }

            Console.WriteLine("Good Bye!");
        }