viernes, 21 de mayo de 2010

Practica extra Problema 3

namespace prob_3
{
class Program
{
static void Main(string[] args)
{
int[] avion = new int[10];
int opcion=0;
int i=0;
int numasciento=0;
for (i = 0; i <= 9; i = i + 1)
{
avion[i] = 0;
}
do
{
Console.WriteLine("1) Primera clase");
Console.WriteLine("2) Clase economica");
Console.Write("Seleccione opcion: ");
opcion = int.Parse(Console.ReadLine());
switch (opcion)
{
case 1:
Console.Write("Numero de asiento entre 1 y 5= ");
numasciento = int.Parse(Console.ReadLine());
if (avion[numasciento - 1] == 1)
{
Console.WriteLine("No disponible");
}
else
{
avion[numasciento - 1] = 1;
Console.WriteLine("No asiento= "+ numasciento);
Console.WriteLine("Primera clase");
}
break;
case 2:
Console.Write("Numero de asiento entre 6 y 10= ");
numasciento = int.Parse(Console.ReadLine());
if (avion[numasciento - 1] == 1)
{
Console.WriteLine("No disponible");
}
else
{
avion[numasciento - 1] = 1;
Console.WriteLine("No asiento= "+ numasciento);
Console.WriteLine("clase economica");
}
break;
default:

Console.WriteLine("opcion equivocada");
break;

}
Console.Write("Presione 0 para salir o 1 para continiar= ");
opcion = int.Parse(Console.ReadLine());
}
while (opcion == 1);
Console.ReadKey();
}
}
}


namespace problema_3_visual_1
{
public partial class Form1 : Form
{
int[] avion = new int[10];
int opcion;
int i;
int c;
int Num_Asiento;
public Form1()
{
InitializeComponent();
listBox1.Items.Add("Seleccione opcion: ");
listBox1.Items.Add("1) Primera clase");
listBox1.Items.Add("2) Clase economica");
}

private void button1_Click(object sender, EventArgs e)
{
opcion=int.Parse(textBox1.Text);
switch (opcion)
{
case 1:
listBox1.Items.Add("Numero de asiente entre 1 y 5");
break;
case 2:
listBox1.Items.Add("Numero de asiento entre 6 y 10");
break;
default:
listBox1.Items.Add("Opcion equivocada");
break;
}
if (i < 10)
{

textBox1.Clear();
textBox1.Focus();
i++;
}
if (i == 10)
{
button1.Enabled = false;
textBox1.Enabled = false;
}


}

private void button2_Click(object sender, EventArgs e)
{
Num_Asiento = int.Parse(textBox2.Text);
for (i = 0; i < 10; i++)
{
avion[i] = 0;
}
if (c < 10)
{

textBox2.Clear();
textBox2.Focus();
c++;
}
if (c == 10)
{
button2.Enabled = false;
textBox2.Enabled = false;
}


}

private void button3_Click(object sender, EventArgs e)
{
if (avion[Num_Asiento - 1] == 1)
{
listBox1.Items.Add(" no disponible");
}
else
{
avion[Num_Asiento - 1] = 1;
listBox1.Items.Add("No. asiento" + Num_Asiento);
listBox1.Items.Add("Primera clase");
}


}

private void button4_Click(object sender, EventArgs e)
{
int[] avion = new int[10];
textBox1.Enabled = true;
textBox2.Enabled = true;
button1.Enabled = true;
button2.Enabled = true;
textBox2.Focus();
textBox1.Focus();
listBox1.Items.Clear();

}

private void button5_Click(object sender, EventArgs e)
{
Close();
}
}
}

No hay comentarios:

Publicar un comentario