Vous êtes sur la page 1sur 6

Etudiant 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ABBADI_V1_2009
{
class Etudiant
{
string CodeE, NomE, Specialite;
DateTime DateNaiss;
public string codeE
{
get { return CodeE; }
set { CodeE = value; }
}
public string nomE
{
get { return NomE; }
set { NomE = value; }
}
public string specialite
{
get { return Specialite; }
set { Specialite = value; }
}
public DateTime dateNaissance
{
get { return DateNaiss; }
set { DateNaiss = value; }
}
public Etudiant(string code, string nom, string specialite,
DateTime dateNaiss)
{
CodeE = code;
NomE = nom;
Specialite=specialite;
DateNaiss = dateNaiss;
}
}
}

Ensignant :
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ABBADI_V1_2009
{
class Enseignant:Personnel
{
int Salaire_brut, NbreHeuresSup;
double Taux_horaire, Taux_IGR;
public int salaire
{
get{return Salaire_brut;}
set{ Salaire_brut=value;}
}
public int nbrHeuresSup
{
get{return NbreHeuresSup;}
set{ NbreHeuresSup=value;}
}
public double taux_horaire
{
get{return Taux_horaire;}
set{ Taux_horaire=value;}
}
public double taux_IGR
{
get{return Taux_IGR;}
set{ Taux_IGR=value;}
}
public Enseignant(string code, string nom, string prenom,
int grade) : base(code, nom, prenom, grade) { }
public Enseignant(string code, string nom, string prenom,
int grade, int salairebrut, int nbrHeuresSup, double tauxHoraire,
double taux_IGR)
: base(code, nom, prenom, grade)
{
Salaire_brut = salairebrut;
NbreHeuresSup = nbrHeuresSup;
Taux_horaire = tauxHoraire;
if (taux_IGR != 0.35 && taux_IGR != 0.42)
throw new TauxIGR_Exception("le taux doit avoir la
valeur 0.35 ou 0.42");
else
Taux_IGR = taux_IGR;
}
}
}
Grade exception :
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ABBADI_V1_2009
{
class GradeExeption:Exception
{
public GradeExeption(string message) : base(message) { }
}
}
Module :
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ABBADI_V1_2009
{
class Module
{
string CodeM, TitreM;
int MasseHoraire;
public string codeM
{
get { return CodeM; }
set { CodeM = value; }
}
public string titreM
{
get { return TitreM; }
set { TitreM = value; }
}
public int masseHoraire
{
get { return MasseHoraire; }
set { MasseHoraire = value; }
}
public Module(string codeM,string titreM,int masseHoraire)
{
CodeM = codeM;
TitreM = titreM;
MasseHoraire = masseHoraire;
}
}
}

Personnel :
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ABBADI_V1_2009
{
class Personnel
{
string Code,Nom,Prenom;
int Grade;
public string code
{
get {return Code;}
set { Code = value; }
}
public string nom
{
get { return Nom; }
set { Nom = value; }
}
public string prenom
{
get { return Prenom; }
set { Prenom = value; }
}
public int grade
{
get { return Grade; }
set { Grade=value; }
}
public Personnel(string code,string nom,string prenom,int
grade)
{
Code = code.Replace("|","");
Nom = nom.Replace("|", "");
Prenom = prenom.Replace("|", "");
if (grade < 16 || grade > 22)
throw new GradeExeption("la grade doit étre entre 16
et 22");
else
Grade = grade;
}
}
}
Programme :
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace ABBADI_V1_2009
{
class Program
{
public enum Masse { SalaireNet, SalaireBrut }
public static void Ajouter(Enseignant ens)
{
StreamWriter sw = new
StreamWriter("Enseignant.txt",true);
sw.WriteLine(ens.code + "|" + ens.grade + "|" +
ens.nbrHeuresSup + "|" + ens.nom + "|" + ens.prenom + "|" +
ens.salaire + "|" + ens.taux_horaire + "|" + ens.taux_IGR);
sw.Close();
}
public static double MasseSalaire(Masse m)
{
double somme=0;
StreamReader sr = new StreamReader("Enseignant.txt");
string s = sr.ReadLine();
string[] str;
if (m == Masse.SalaireNet)
{
while (s != null)
{
str = s.Split('|');
somme = somme + SalaireNet(new Enseignant(str[0],
str[3], str[4], Convert.ToInt32(str[1]), Convert.ToInt32(str[5]),
Convert.ToInt32(str[2]), Convert.ToDouble(str[6]),
Convert.ToDouble(str[7])));
s = sr.ReadLine();
}

}
else
{
while (s != null)
{
str = s.Split('|');
somme = somme + Convert.ToInt32(str[5]);
s = sr.ReadLine();
}
}
sr.Close();
return somme;
}
public static void Modifier(Enseignant En)
{
StreamReader sr = new StreamReader("Enseignant.txt");
StreamWriter sw;
string[] str;
string st = null;
string s = sr.ReadLine();
while (s != null)
{
str = s.Split('|');
if (str[0].Equals(En.code))
{
st = st + En.code + "|" + En.grade + "|" +
En.nbrHeuresSup + "|" + En.nom + "|" + En.prenom + "|" + En.salaire +
"|" + En.taux_horaire + "|" + En.taux_IGR +Environment.NewLine;
}
else
st = st + s + Environment.NewLine;
s = sr.ReadLine();
}
sr.Close();
sw = new StreamWriter("Enseignant.txt", false);
sw.Write(st);
sw.Close();
}
public static void Supprimer(Enseignant En)
{
StreamReader sr = new StreamReader("Enseignant.txt");
StreamWriter sw;
string[] str;
string st=null;
string s = sr.ReadLine();
while (s != null)
{
str = s.Split('|');
if (!str[0].Equals(En.code))
{
st = st + s+Environment.NewLine;
}
s = sr.ReadLine();
}
sr.Close();
sw = new StreamWriter("Enseignant.txt",false);
sw.Write(st);
sw.Close();
}
public static void Afficher()
{
FileStream fs = new FileStream("Enseignant.txt",
FileMode.OpenOrCreate);
fs.Close();
StreamReader sr = new StreamReader("Enseignant.txt");
string s=sr.ReadLine();
string[] str;

Console.WriteLine("==================================================
=========");
Console.WriteLine("================== Liste des
Enseignants ==================");
while (s != null)
{
str = s.Split('|');
Console.WriteLine("==================================================
=========");
Console.WriteLine("Code : " +
str[0]);
Console.WriteLine("Nom : " +
str[3]);
Console.WriteLine("Prénom : " +
str[4]);
Console.WriteLine("Grade : " +
str[1]);
Console.WriteLine("Salaire : " +
str[5]);
Console.WriteLine("Heures supplimentaires : " +
str[2]);
Console.WriteLine("Taux haoraire : " +
str[6]);
Console.WriteLine("Taux IGR : " +
str[7]);

Console.WriteLine("==================================================
=========");
s = sr.ReadLine();
}
sr.Close();
}
public static double SalaireNet(Enseignant En)
{
return((En.salaire+(En.nbrHeuresSup*En.taux_horaire))*(1-
En.taux_IGR));
}
static void Main(string[] args)
{
}
}
}

Vous aimerez peut-être aussi