Advertisement
LePetitGlacon

POO 1

Jan 6th, 2020
159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.03 KB | None | 0 0
  1. using System;
  2.  
  3. namespace u
  4. {
  5.     class Program
  6.     {
  7.         public static void Main()
  8.         {
  9.  
  10.             int nbParticipants;
  11.             int i = 0;
  12.            
  13.             Console.WriteLine("Combien avez vous de participants ?");
  14.             nbParticipants = int.Parse(Console.ReadLine());
  15.             Participant[] tabParticipant = new Participant[nbParticipants];
  16.            
  17.             for (i = 0; i < nbParticipants; i++) {
  18.                 tabParticipant[i] = FonctionSaisie(i);
  19.             }
  20.            
  21.             int tempsMini = tabParticipant[0].temps;
  22.             int Num_candidat = 0;
  23.            
  24.             for (i = 0; i < tabParticipant.Length; i++) {
  25.                
  26.                
  27.                 if (tempsMini > tabParticipant[i].temps)
  28.                 {
  29.                     tempsMini = tabParticipant[i].temps;
  30.                     Num_candidat = i;
  31.                 }  
  32.             }
  33.            
  34.             Console.WriteLine("\nLe temps le plus rapide est celui du candidat {0} et il est de {1} secondes pénalités incluses.", Num_candidat+1, tempsMini );
  35.             Console.WriteLine("\nSon chrono initial est de {0} minutes et  {1} secondes. Il a touché {2} et couché {3} obstacle(s).",tabParticipant[Num_candidat].minute,tabParticipant[Num_candidat].seconde,tabParticipant[Num_candidat].nbTouché,tabParticipant[Num_candidat].nbCouché);
  36.            
  37.             Console.ReadKey(true);
  38.         }
  39.        
  40.         /// < summary>
  41.         /// Fonction saisissant les informations d'un participant et calcul son temps
  42.         /// < /summary>
  43.         /// < param name="indice">L'indice du participant pour l'affichage< /param>
  44.         /// < returns>le participant saisi< /returns>
  45.         static Participant FonctionSaisie(int indice)
  46.         {
  47.             Console.WriteLine("Entrez le temps du candidats N°{0} : (minutes puis secondes)", indice + 1);
  48.             int minute = int.Parse(Console.ReadLine());
  49.             int seconde = int.Parse(Console.ReadLine());
  50.             Console.WriteLine("Combien d'obstacle le candidats a-t-il touché ?");
  51.             int nbTouché = int.Parse(Console.ReadLine());
  52.             Console.WriteLine("Combien d'obstacle le candidats a-t-il renversés ?");
  53.             int nbCouché = int.Parse(Console.ReadLine());
  54.            
  55.             return new Participant(minute, seconde, nbTouché, nbCouché);
  56.         }
  57.     }
  58.    
  59.     class Participant{
  60.         public int minute;
  61.         public int seconde;
  62.         public int nbTouché;
  63.         public int nbCouché;
  64.         public int temps;
  65.  
  66.  
  67.         /// < summary>
  68.         /// Construit et paramètre un participant, n'oubliez pas le calcul du temps !
  69.         /// < /summary>
  70.         public Participant(int aminute,int aseconde,int anbTouché,int anbCouché)
  71.         {
  72.             minute = aminute;
  73.             seconde = aseconde;
  74.             nbTouché = anbTouché;
  75.             nbCouché = anbCouché;
  76.             temps =  aminute * 60 + aseconde + anbTouché * 5 + anbCouché * 10;
  77.            
  78.            
  79.         }
  80.     }
  81. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement