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
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ClasseEtudiant
//nom generique ClasseEtudiant
{
public class etudiant// definition classe principale etudiant
{
// declaration dates membres qui peuvent etre acceder par d'autres programmes
public string nom, prenom, sexe, ville;
public int age;
public float note;
public etudiant() // implementation constructeur implicit
{
nom = "";
prenom = "";
sexe = "";
ville = "";
age = 0;
note = 0;
}
public etudiant(string n, string p, string s, string v, int a, float not) //implementation constructeur avec parametre
{
nom = n;
prenom = p;
sexe = s;
ville = v;
age = a;
note = not;
}
// fonction quelle_note retourne une valeur de type float
public float quelle_note() // fonction quel_note pour voir la promovation d'un examen
{
if (note >= 5 && note <= 10)
Console.WriteLine("L'etudiant a promove l'examen");
else
Console.WriteLine("L'etudiant n'a pas promove l'examen");
return note;
}
//affichage informations etudiants - en ce cas 3 dates membres //nom,prenom, note pour chaque objet de la classe etudiant-donc pour //chaque etudiant on affiche seulement ces 3 informations(nom,prenom et //note)
public void informations() // functie membru afisare informatii
{
Console.WriteLine(string.Format("{0} {1} : {2}", nom, prenom, note));
}
}
static class Program
{
//Programme principal C#
public static void Main(string[] args) //dans le programme principale on va creer 4 objets nomme a,a1,a2 et a3 pour la classe nomme etudiant
//instantions des objets - en ce cas nous avons 4 objets
{
etudiant a = new etudiant("Prevost", "Marcel", "M", "Paris", 20, 9.02f);
etudiant a1 = new etudiant("Prevost", "Eugene", "M", "Lille", 21, 9f);
etudiant a2 = new etudiant("Lafont", "Virginie", "F", "Marseille", 22, 8f);
etudiant a3 = new etudiant("Colpin", "Michel", "M", "Rennes", 29, 7.02f);
a.informations();
a1.informations();
a2.informations();
a3.informations();
}
}
} |
Partager