Вы находитесь на странице: 1из 16

INTRODUCCIÓN A LA PROGRAMACIÓN

Fase 4 – Administrar datos en arreglos


(Problema 2)

Presentado al tutor:
MARIA DEL CARMEN BENAVIDEZ

Estudiante:
ADOLFO SANDOVAL AGUDELO

Cod: 1144183919

Grupo
62

UNIVERSIDAD ACIONAL ABIERTA Y A DISTANCIA – UNAD


ESCUELA DE CIENCIAS BASICAS TECNOLOGICA E INGENIERIA
NOVIEMBRE DE 2019
IDENTIFICACIÓN DE LA CLASE

Requerimientos Descripción Entradas Resultados de salida

R1 registrar a las Variable 6 datos almacenados en las


personas que tipo entero variables nombre, numero
quieren y cadenas de cedula, edad, puntaje de
postularse al de texto estudio, puntaje de edad
cargo de
instructor

R2 Imprimir la lista Variable La variable acumulara la


de los postulados tipo String respuesta de los usuarios
que
acumula
los
registros.

R3 Modificar datos Variable Cambio de datos en el


tipo entero puesto seleccionado,
y cadenas excepto el número de
de texto cedula
IDENTIFICACIÓN DE REQUERIMIENTOS
class Program

string id;
public string level;
public int punStudy;
public int age;
public int puntosage;
public string name;
• public static void menu()
• static void Main

Entrevista

string id;
public string level;
public int punStudy;
public int age;
public int puntosage;
public string name;
• entrevista
• Buscar
• Modificar
• imprimirDatos()
CÓDIGO DEL PROGRAMA

DATOS

namespace problema_2_taller_4
{
class Datos
{

string id;
public string level;
public int punStudy;
public int age;
public int puntosage;
public string name;
public Datos(string name, string id, string level, int age, int punStudy,
int puntosage)
{
this.name = name;
this.id = id;
this.level = level;
this.age = age;
this.punStudy = punStudy;
this.puntosage = puntosage;

public int getage()


{
return age;
}
public string getid()
{
return id;
}

public string getlevel()


{
return level;
}

public int getPuntosage()


{
return puntosage;
}
public int getpunStudy()
{
return punStudy;
}
public string getname()
{
return name;
}
public String toString()
{
string msj = “\n=================\n”;
msj += “\nNúmero de Identificación: “ + this.id;
msj += “\nNombre: “ + this.name;
msj += “\nEdad: “ + this.age;
msj += “\nNivel Acádemico: “ + this.level;
msj += “\nPuntaje Nivel 5cadémico: “ + this.punStudy;
msj += “\nPuntaje por Edad: “ + this.puntosage;
msj += “\nPuntaje total: “ + (this.puntosage + this.punStudy);

return msj;

}
}
}

ENTREVISTA

namespace problema_2_taller_4
{
class entrevista
{
Datos[] entrevistados;
int CantMax = 3;
int cont;

public entrevista(int CantMax)


{
this.CantMax = CantMax;
this.entrevistados = new Datos[CantMax];
this.cont = 0;

public void insertar(string name, string id, string level, int age, int
punStudy, int puntosage)
{
entrevistados[cont] = new Datos(name, id, level, age, punStudy,
puntosage);
cont++;

public int buscar(String id)


{
int bandera = -1;
for (int i = 0; i < cont; i++)
{
if (entrevistados[i].getid().Equals(id))
{
bandera = i;
break;
}
}
return bandera;

public void actualizar(int pos, string name, string level, int age, int
punStudy, int puntosage) // Metodo para actualizar
{
entrevistados[pos].name = name;
entrevistados[pos].level = level;
entrevistados[pos].age = age;
entrevistados[pos].punStudy = punStudy;
entrevistados[pos].puntosage = puntosage;

public Datos mejorCandidato()


{
Datos mayorPuntaje = null;
int mayor = 0;

for (int i = 0; i < cont; i++)


{
int total = entrevistados[i].getpunStudy() +
entrevistados[i].getPuntosage();
if (total > mayor)
{
mayor = total;
mayorPuntaje = entrevistados[i];
}
}

return mayorPuntaje;
}

public void Imprimir()


{
for (int i = 0; i < cont; i++)
{
if (cont > 0)
{
Console.WriteLine(entrevistados[i].toString());

Console.WriteLine(" ");
Console.WriteLine("Presione la tecla Enter para volver al menú
principal");

}
public int getCont()
{
return cont;
}
public int getCantMax()
{
return CantMax;
}

PROGRAMA

namespace problema_2_taller_4
{

class Program
{

static void Main(string[] args)


{
int op = 0;

registros = new entrevista(3);


registros.getCantMax();

Console.WriteLine("Recuerde que hay un limite de 3 personas a


entrevistar");
Console.WriteLine("Presione la tecla Enter para continuar");
Console.ReadLine();

do
{
menuPrincipal();
op = int.Parse(Console.ReadLine());

switch (op)
{
case 1:
Console.Clear();
insertar();
Console.ReadLine();
break;

case 2:
Console.Clear();

registros.Imprimir();
Console.ReadLine();
break;

case 3:
Console.Clear();

Console.WriteLine("El mejor candidato es: " +


registros.mejorCandidato().toString());
Console.WriteLine(" ");
Console.WriteLine("Presione la tecla Enter para volver al
menú principal");

Console.ReadLine();
break;

case 4:
Console.Clear();

actualizarRegistro();
Console.WriteLine(" ");
Console.WriteLine("Presione la tecla Enter para volver al
menú principal");
Console.ReadLine();
break;

} while (op != 5);

if (op == 5)
{
Console.Clear();
Console.WriteLine("");
Console.WriteLine("");
Console.WriteLine("");
Console.WriteLine(" Agradecemos
por utilizar nuestra aplicación :)");

Console.ReadLine();
}

}
static entrevista registros = null;
public static void menuPrincipal()
{
Console.Clear();

Console.WriteLine("*****************************************************************
******************* ");
Console.WriteLine(" Entrevista Instructor
Sena");

Console.WriteLine("*****************************************************************
******************* ");
Console.WriteLine(" ");
Console.WriteLine("1.Entrevistar persona");
Console.WriteLine("2.Ver puntaje de los entrevistados");
Console.WriteLine("3.Ver el mejor candidato");
Console.WriteLine("4.Modificar");
Console.WriteLine("5.Salir");
Console.WriteLine(" ");
Console.WriteLine("Digite una opción");

public static void insertar()


{
if (registros.getCont() < registros.getCantMax())
{
string name;
string id;
string level = "";
int age;
int punStudy = 0;
int puntosage = 0;
Console.WriteLine("Ingrese nombre completo por favor:");
name = Console.ReadLine();
Console.WriteLine("Ingrese su número de cédula:");
id = Console.ReadLine();
int res = registros.buscar(id);
if (res == -1)
{
do
{
int op;
Console.WriteLine("Digite su nivel educativo");
Console.WriteLine("_________________________");
Console.WriteLine("1.Tecnólogo");
Console.WriteLine("2.Profesional");
Console.WriteLine("_________________________");

op = int.Parse(Console.ReadLine());
switch (op)
{

case 1:
punStudy = 5;
level = "Técnologo";
break;

case 2:
punStudy = 10;
level = "Profesional";
break;

} while (punStudy == 0);

Console.WriteLine("Ingrese Edad");
age = int.Parse(Console.ReadLine());

if (age > 18 && age <= 30)


{
puntosage = 20;
}
if (age > 30)
{
puntosage = 10;
}

registros.insertar(name,id, level, age, punStudy, puntosage);


Console.WriteLine("********************************************
");
Console.WriteLine("El registro ha sido creado exitosamente ");
Console.WriteLine("********************************************
");
Console.WriteLine(" ");
Console.WriteLine("Presione la tecla Enter para volver al menú
principal");

else
{
Console.WriteLine("El registro ya existe");
}
}

else
{
Console.WriteLine("******************************************");
Console.WriteLine("Lo sentimos excedio el limite de candidatos");
Console.WriteLine("******************************************");
Console.WriteLine("Presione la tecla Enter para volver al menú
principal");
}
}

public static void actualizarRegistro()


{

string name;
string id;
string level = "";
int age;
int punStudy = 0;
int puntosage = 0;

Console.WriteLine("Ingrese su número de cédula");


id = Console.ReadLine();
int res = registros.buscar(id);
if (res != -1)
{

Console.WriteLine("Ingrese su nombre");
name = Console.ReadLine();

do
{
int op;
Console.WriteLine("Digite su nivel educativo");
Console.WriteLine("_________________________");
Console.WriteLine("1.Tecnólogo");
Console.WriteLine("2.Profesional");

op = int.Parse(Console.ReadLine());
switch (op)
{

case 1:
punStudy = 5;
level = "Técnologo";
break;

case 2:
punStudy = 10;
level = "Profesional";
break;

} while (punStudy == 0);

Console.WriteLine("Ingrese su Edad");
age = int.Parse(Console.ReadLine());

if (age > 18 && age <= 30)


{
puntosage = 20;
}

if (age > 30)


{
puntosage = 10;
}

registros.actualizar(res, name, level, age, punStudy, puntosage);


Console.WriteLine("Registro actualizado");
}

else
{
Console.WriteLine("El registro no se encontro");
}

}
}
}

CAPTIURAS DE PANTALLA DEL CODIGO Y EJECUCION


REFERENCIAS

• Oviedo, R. E. (2015). Lógica de programación orientada a


objetos. (pp. 179 – 231). Colombia: ECOE Ediciones.
Recuperado de
https://bibliotecavirtual.unad.edu.co:2538/lib/unadsp/read
er.action?docID=4909249
• Schildt, H. (2010). Fundamentos de C# 3.0. (pp. 119 -
151). Madrid, ES: McGraw-Hill España. Recuperado de
http://bibliotecavirtual.unad.edu.co:2077/lib/unadsp/reade
r.action?docID=10515217&ppg=136
• Benavides, M. (2018). Creando una clase con sus métodos.
[Video] Recuperado de http://hdl.handle.net/10596/22363
• Ceballos, S. F. J. (2007). Microsoft C#: lenguaje y
aplicaciones (2a. ed.). (pp. 28 - 53). Madrid, ES: RA-MA
Editorial. Recuperado de
http://bibliotecavirtual.unad.edu.co:2077/lib/unadsp/reade
r.action?docID=11046613&ppg=49
• OVI Unidad 2 Clases y métodos
Benavides, M. (2016). Clases y Métodos. [Video]
Recuperado de http://hdl.handle.net/10596/9633

Вам также может понравиться