
05/03/2008, 19:37
|
| | Fecha de Ingreso: febrero-2008 Ubicación: Macuspana,Tabasco
Mensajes: 33
Antigüedad: 17 años Puntos: 0 | |
Re: Borrar Un Dato Especifico En Un ArrayList C# te voy a mandar todo el codigo.
ESTE ES LA CLASE PRINCIPAL.
using System;
using System.Collections;
using System.Text;
using Programa;
namespace Pro
{
class Principal
{
static void Main()
{
int op = 0;
do
{
Console.Clear();
Console.WriteLine(" Menu de altas de maestros y alumnos");
Console.WriteLine("1.-ALTA DE ALUMNOS");
Console.WriteLine("2.-ALTA DE MAESTRO");
Console.WriteLine("SI DESEA SALIR PRESIONE 0");
Console.WriteLine(".....ESCOJA UNA DE LAS OPCIONES");
op = int.Parse(Console.ReadLine());
switch (op)
{
case 0:
Console.WriteLine("usted deseo salir del sistema");
break;
case 1:
Alumno a = new Alumno();
a.menualum();
break;
case 2:
Maestro ma = new Maestro();
ma.menumaes();
break;
default:
Console.WriteLine("la opcion no es correcta");
break;
}
}
while (op != 0);
}
}
}
ESTE ES LA CLASE PERSONA
using System;
using System.Collections;
using System.Text;
namespace Programa
{
class Persona
{
public string nombre;
public int edad;
public Persona()
{
this.nombre = "";
this.edad = 0;
}
public override string ToString()
{
return nombre + edad;
}
}
}
ESTE ES LA CLASE MAESTRO.
using System;
using System.Collections;
using System.Text;
namespace Programa
{
class Maestro: Persona,Comunes
{
int clave;
int salario;
ArrayList maes = new ArrayList();
public Maestro()
{
this.clave = 0;
this.salario = 0;
}
public void menumaes()
{
int retorno = 1;
while (retorno == 1)
{
Console.Clear();
Console.WriteLine("OPCIONES PARA MAESTROS");
Console.WriteLine("1.-GUARDAR");
Console.WriteLine("2.-ELIMINAR");
Console.WriteLine("3.-CONSULTAR");
Console.WriteLine("ESCOJA UNA DE LAS OPCIONES");
int opci = int.Parse(Console.ReadLine());
if (opci == 1)
{
alta();
}
if (opci == 2)
{
baja();
}
if (opci == 3)
{
consulta();
}
if ((opci < 1) || (opci > 3))
{
Console.WriteLine("opcion incorrecta");
}
Console.WriteLine("desea realizar otra operacion 1 o 0");
retorno = int.Parse(Console.ReadLine());
}
}
public void alta()
{
object[] maestro = new object[4];
Console.WriteLine("escriba los datos del maestro");
Console.Write("nombre");
maestro[0] = (Console.ReadLine());
Console.Write("edad");
maestro[1] = int.Parse(Console.ReadLine());
Console.Write("clave");
maestro[2] = int.Parse(Console.ReadLine());
Console.Write("salario");
maestro[3] = int.Parse(Console.ReadLine());
maes.Add(maestro);
Console.WriteLine("los datos de alumnos han sido guardados");
}
public void baja()
{
Console.WriteLine("dar de baja a un maestro");
}
public void consulta()
{
Console.WriteLine("consultar todos los datos de los maestros");
}
public override string ToString()
{
return nombre + edad + salario + clave;
}
}
}
ESTE ES LA INTERFACE.
using System;
using System.Collections;
using System.Text;
namespace Programa
{
interface Comunes
{
void alta();
void baja();
void consulta();
}
}
ESTA ES LA CLASE ALUMNO Y ES TODO
using System;
using System.Collections;
using System.Text;
namespace Programa
{
class Alumno : Persona, Comunes //SE HEREDA PERSONA Y LA INTERFACE
{
ArrayList alum = new ArrayList();
int matricula;
string carrera = "";
public Alumno()
{
this.matricula = 0;
this.carrera = "";
}
public void menualum()
{
int retorno = 1;
while (retorno == 1)
{
Console.Clear();
Console.WriteLine("OPCIONES PARA ALUMNOS");
Console.WriteLine("1.-GUARDAR");
Console.WriteLine("2.-ELIMINAR");
Console.WriteLine("3.-CONSULTAR");
Console.WriteLine("ESCOJA UNA DE LAS OPCIONES");
int opci = int.Parse(Console.ReadLine());
if (opci == 1)
{
alta();
}
if (opci == 2)
{
baja();
}
if (opci == 3)
{
consulta();
}
if ((opci < 1) || (opci > 3))
{
Console.WriteLine("opcion incorrecta");
}
Console.WriteLine("desea realizar otra operacion 1 o 0");
retorno = int.Parse(Console.ReadLine());
}
}
public void alta()
{
object[] estudiante = new object[4];
Console.WriteLine("escriba los datos del alumno");
Console.Write("matricula");
estudiante[0] = int.Parse(Console.ReadLine());
Console.Write("nombre");
estudiante[1] = int.Parse(Console.ReadLine());
Console.Write("edad");
estudiante[2] = int.Parse(Console.ReadLine());
Console.Write("carera");
estudiante[3] = int.Parse(Console.ReadLine());
alum.Add(estudiante);
Console.WriteLine("los datos de alumnos han sido guardados");
}
public void baja()
{
Console.WriteLine("dar de baja a un alumno");
}
public void consulta()
{
//Console.WriteLine("consultar todos los datos de los alumnos");
foreach (object j in ArrayList) /// AQUI ES DONDE QUIERO HACER LA CONSULTA
Console.WriteLine(alum.ToString());
}
public override string ToString()
{
return nombre + edad + matricula + carrera;
}
}
}
LOQUE ME FALTA ES HACER EL METODO BAJAS UNO POR UNO DEPENDIENDO CUANTOS REGISTRO SE HAYAN CAPTURADO. Y EL DE CONSULTA GENERAL.
GRACIAS..DE ANTEMANO |