Advertisement
idroj07

EJ1_EXFINAL4_Prog_Filtrado_T6-7

May 8th, 2019
314
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 4.20 KB | None | 0 0
  1. class ListaEmpleados
  2.     {
  3.         private ArrayList mPlantilla = new ArrayList();
  4.         private ArrayList mPlantillaVIP = new ArrayList();
  5.         private int mMediaVentas;
  6.         public int MediaVentas
  7.         {
  8.             get { return mMediaVentas; }
  9.             set { mMediaVentas = value; }
  10.         }
  11.        
  12.         //a)
  13.         public string cumpleEmpEl(int dia, int mes)
  14.         {
  15.             string empleados = "";
  16.  
  17.             foreach (Empleado xEmpleado in mPlantilla)
  18.             {
  19.                 if (xEmpleado.MesNac == mes)
  20.                 {
  21.                     if (xEmpleado.DiaNac == dia)
  22.                         empleados += xEmpleado.Nombre + " , ";
  23.                 }
  24.             }
  25.             return empleados;
  26.         }
  27.         //b)
  28.         public void ordxCumple()
  29.         {
  30.             for (int i = 0; i < mPlantilla.Count-1; i++)
  31.             {
  32.                 for (int j = i+1; j < mPlantilla.Count; j++)
  33.                 {
  34.                     Empleado xEmpI = (Empleado)mPlantilla[i];
  35.                     Empleado xEmpJ = (Empleado)mPlantilla[j];
  36.  
  37.                     if (xEmpI.MesNac >= xEmpJ.MesNac)
  38.                     {
  39.                         if (xEmpI.MesNac == xEmpJ.MesNac)
  40.                         {
  41.                             if (xEmpI.DiaNac > xEmpJ.DiaNac)
  42.                             {
  43.                                 mPlantilla[i] = xEmpJ;
  44.                                 mPlantilla[j] = xEmpI;
  45.                             }
  46.                         }
  47.                         else
  48.                         {
  49.                             mPlantilla[i] = xEmpJ;
  50.                             mPlantilla[j] = xEmpI;
  51.                         }
  52.                     }
  53.                 }
  54.             }
  55.         }
  56.  
  57.         //c)
  58.         public string EmpconVentasMayMedia()
  59.         {
  60.             string empleados = "";
  61.  
  62.             foreach (Empleado xEmp in mPlantilla)
  63.             {
  64.                 if (xEmp.sumVentas() > MediaVentas)
  65.                 {
  66.                     empleados += xEmp.Nombre + " , ";
  67.                 }
  68.             }
  69.             return empleados;
  70.         }
  71.         //d)
  72.         public void moverAvip()
  73.         {
  74.             foreach (Empleado xEmp in mPlantilla)
  75.             {
  76.                 if (xEmp.Nventas()>5 && xEmp.ventasSuperan(100))
  77.                 {
  78.                     mPlantillaVIP.Add(xEmp);
  79.                     mPlantilla.Remove(xEmp);
  80.                 }
  81.             }
  82.         }
  83.     }
  84.  
  85.  
  86. /////////////  AQUI LA CLASE EMPLEADO  ///////////////////////////////////////////////////////////////////////////////
  87.  
  88. class Empleado
  89.     {  //Declaración de miembros de clase.
  90.         private string mNombre;
  91.         private int mEdad;
  92.         private int mDiaNac;
  93.         private int mMesNac;
  94.         //Aquí ventas realizadas por el empleado.
  95.         private ArrayList mVentas;
  96.         //Constructor
  97.         public Empleado()
  98.         {
  99.             mNombre = "";
  100.             mEdad = 0;
  101.             //Creamos la lista de ventas.
  102.             mVentas = new ArrayList();
  103.         }
  104.         public int DiaNac
  105.         {
  106.             get { return mDiaNac; }
  107.             set { mDiaNac = value; }
  108.         }
  109.         public int MesNac
  110.         {
  111.             get { return mMesNac; }
  112.             set { mMesNac = value; }
  113.         }
  114.         public string Nombre
  115.         {
  116.             get { return Nombre; }
  117.             set { Nombre = value; }
  118.         }
  119.         public int Edad
  120.         {
  121.             get { return mEdad; }
  122.             set { mEdad = value; }
  123.         }
  124.  
  125.         public int sumVentas()
  126.         {
  127.             int sumatorio=0;
  128.  
  129.             foreach (int venta in mVentas)
  130.             {
  131.                 sumatorio += venta;
  132.             }
  133.             return sumatorio;
  134.         }
  135.         public int Nventas()
  136.         {
  137.             int total = mVentas.Count;
  138.             return total;
  139.         }
  140.         public bool ventasSuperan(int cantidad)
  141.         {
  142.             bool superan = true;
  143.  
  144.             foreach (int venta in mVentas)
  145.             {
  146.                 if (venta <= 100)
  147.                 {
  148.                     superan = false;
  149.                 }
  150.             }
  151.             return superan;
  152.         }
  153.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement