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
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ClasseEtudiant //nom generique ClasseEtudiant
{
class etudiant // nom du programme avec l'extension .cs en ce cas //etudiant.cs
{
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("nom"+"prenom"+"note");
}
//destructeur
~etudiant()
{ nom="";
prenom="";
sexe="";
ville="";
age=0;
note=0;
}
}
} % fin de la classe etudiant
//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("Prevost", "Marcel",20,"M","Paris",9.02);
etudiant a1("Prevost", "Eugene",21,"M","Lille",9); /
etudiant a2("Lafont", "Virginie",22,"F","Marseille",8);
etudiant a3("Colpin", "Michel",29,"M","Rennes",7.02); /
a.informations();
a1.informations();
a2.informations();
a3.informations();
}
} |
Partager