Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class ListaEmpleados
- {
- private ArrayList mPlantilla = new ArrayList();
- private ArrayList mPlantillaVIP = new ArrayList();
- private int mMediaVentas;
- public int MediaVentas
- {
- get { return mMediaVentas; }
- set { mMediaVentas = value; }
- }
- //a)
- public string cumpleEmpEl(int dia, int mes)
- {
- string empleados = "";
- foreach (Empleado xEmpleado in mPlantilla)
- {
- if (xEmpleado.MesNac == mes)
- {
- if (xEmpleado.DiaNac == dia)
- empleados += xEmpleado.Nombre + " , ";
- }
- }
- return empleados;
- }
- //b)
- public void ordxCumple()
- {
- for (int i = 0; i < mPlantilla.Count-1; i++)
- {
- for (int j = i+1; j < mPlantilla.Count; j++)
- {
- Empleado xEmpI = (Empleado)mPlantilla[i];
- Empleado xEmpJ = (Empleado)mPlantilla[j];
- if (xEmpI.MesNac >= xEmpJ.MesNac)
- {
- if (xEmpI.MesNac == xEmpJ.MesNac)
- {
- if (xEmpI.DiaNac > xEmpJ.DiaNac)
- {
- mPlantilla[i] = xEmpJ;
- mPlantilla[j] = xEmpI;
- }
- }
- else
- {
- mPlantilla[i] = xEmpJ;
- mPlantilla[j] = xEmpI;
- }
- }
- }
- }
- }
- //c)
- public string EmpconVentasMayMedia()
- {
- string empleados = "";
- foreach (Empleado xEmp in mPlantilla)
- {
- if (xEmp.sumVentas() > MediaVentas)
- {
- empleados += xEmp.Nombre + " , ";
- }
- }
- return empleados;
- }
- //d)
- public void moverAvip()
- {
- foreach (Empleado xEmp in mPlantilla)
- {
- if (xEmp.Nventas()>5 && xEmp.ventasSuperan(100))
- {
- mPlantillaVIP.Add(xEmp);
- mPlantilla.Remove(xEmp);
- }
- }
- }
- }
- ///////////// AQUI LA CLASE EMPLEADO ///////////////////////////////////////////////////////////////////////////////
- class Empleado
- { //Declaración de miembros de clase.
- private string mNombre;
- private int mEdad;
- private int mDiaNac;
- private int mMesNac;
- //AquĆ ventas realizadas por el empleado.
- private ArrayList mVentas;
- //Constructor
- public Empleado()
- {
- mNombre = "";
- mEdad = 0;
- //Creamos la lista de ventas.
- mVentas = new ArrayList();
- }
- public int DiaNac
- {
- get { return mDiaNac; }
- set { mDiaNac = value; }
- }
- public int MesNac
- {
- get { return mMesNac; }
- set { mMesNac = value; }
- }
- public string Nombre
- {
- get { return Nombre; }
- set { Nombre = value; }
- }
- public int Edad
- {
- get { return mEdad; }
- set { mEdad = value; }
- }
- public int sumVentas()
- {
- int sumatorio=0;
- foreach (int venta in mVentas)
- {
- sumatorio += venta;
- }
- return sumatorio;
- }
- public int Nventas()
- {
- int total = mVentas.Count;
- return total;
- }
- public bool ventasSuperan(int cantidad)
- {
- bool superan = true;
- foreach (int venta in mVentas)
- {
- if (venta <= 100)
- {
- superan = false;
- }
- }
- return superan;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement