Practica Tres Delphi

Loading...

Flash Player 9 (or above) is needed to view presentations.
We have detected that you do not have it on your computer. To install it, go here.

0 comments

Post a comment

    Post a comment
    Embed Video
    Edit your comment Cancel

    Favorites, Groups & Events

    Practica Tres Delphi - Presentation Transcript

    1. I.S.T. “F.P.G.V.” Computación e Informática Programación Distribuida y Concurrente GUÍA DE LABORATORIO N° 03 OBJETIVOS: • Manejo de diversos controles, sus propiedades, métodos y eventos • Estructuras de control: Decisión, Repetitivas • Uso de variables. 1.1 CONSIDERACIONES INICIALES Debe abrir su proyecto de la guía de laboratorio Nº 02, y deberá agregar formularios para las aplicaciones siguientes: 1.2 CREACIÓN DE LA UNIDAD DE CÓDIGO DELPHI “MÓDULO” FORMULARIO (Factorial.pas) a) En el formulario inserte los controles necesarios y establezca las propiedades necesarias para obtener la siguiente apariencia:==> b) Ahora procedemos a establecer la Propiedades a los objetos, principalmente la propiedad (Name): Objeto Propiedad Valor Asignado Form1 Name FrmFactorial Edit1 Name edNumero Edit2 Name edFactorial Edit3 Name edSuma Button1 Name btnCalcular Button2 Name btnSalir NOTA: establezca las demás propiedades que usted crea conveniente. c) Ahora proceda a escribir el código correspondiente a los objetos necesarios: Objeto: btnCalcular Evento: OnClick procedure TfrmFactorial.btnCalcularClick(Sender: TObject); var i,n:Integer; f,s:Double; begin //Entrada de datos n:=strtoint(ednumero.Text); //Proceso //calcular el factorial f:=1; for i:=1 to n do begin f:=f*i; end; //Calcular la suma de n pares i:=2; s:=0; while (i <= n) do begin s:=s+i; i:=i+2; end; Docente: Lic. José Luis Ponce Segura www.vigilvirtual.com Prac03 (1 de 7)
    2. I.S.T. “F.P.G.V.” Computación e Informática Programación Distribuida y Concurrente // Imprimir resultados edfactorial.Text:=floattostr(f); edsuma.text:=floattostr(s); end; Objeto: btnSalir Evento: Onclick procedure TfrmCalificaciones.btnSalirClick(Sender: TObject); begin close; end; 1.3 CREACIÓN DE LA UNIDAD DE CÓDIGO DELPHI “MÓDULO” (Movimientos.pas) a) En el formulario inserte los controles necesarios y establezca las propiedades necesarias para obtener la siguiente apariencia: a) Ahora procedemos a establecer la Propiedad (Name) que se puede apreciar en a imagen para las cajas de texto y etiquetas: edCliente, edMonto, lblCantDeposito, lblTotalDeposito, lblCantRetiro, lblTotalRetiro, lblSaldo. Así también establezca el (Name) para los botones como son: BtnAceptar, BtnDeposito, BtnRetiro, BtnNuevo, BtnSalir. b) Ahora proceda a escribir el código correspondiente: Declare las variables cd, cr, td, tr, saldo según se observa a continuación: Objeto: frmMovimientos Evento: OnCreate procedure TfrmMovimientos.FormCreate(Sender: TObject); begin limpiar; end; Docente: Lic. José Luis Ponce Segura www.vigilvirtual.com Prac03 (2 de 7)
    3. I.S.T. “F.P.G.V.” Computación e Informática Programación Distribuida y Concurrente Procedimiento creado por el Usuario Procedure TfrmMovimientos.limpiar; begin cd:= 0; cr:= 0; td:= 0; tr:= 0; saldo:=0; edCliente.clear; edMonto.Text := ''; lblCantDeposito.caption :=''; lblCantRetiro.caption := ''; lblSaldo.caption := ''; lblTotalDeposito.caption := ''; lblTotalRetiro.caption :=''; btnAceptar.Visible := True; btnDeposito.Enabled := False; btnRetiro.Enabled := False; edCliente.ReadOnly := False; edMonto.ReadOnly := True; end; Ahora deberá establecer el procedimiento recientemente creado en el Area Type Type TfrmMovimientos = class(TForm) YYYYYY; ZZZZZZ; procedure limpiar; // Sólo agregue ésta línea Objeto: btnAceptar Evento: OnClick procedure TfrmMovimientos.btnAceptarClick(Sender: TObject); begin edCliente.ReadOnly := True; edMonto.ReadOnly := False; btnAceptar.Visible := False; btnDeposito.Enabled := True; btnRetiro.Enabled := True; // ingresar el saldo inicial saldo := strtofloat(InputBox(‘Nueva Cuenta’,’Ingrese el Monto de Apertura: ‘, ‘350’)); lblSaldo.caption := floattostr(saldo); td := saldo; cd := 1; lblCantDeposito.caption := inttostr(cd); lblTotalDeposito.caption := floattostr(td); edMonto.setfocus; end; Objeto: btnDeposito Evento: Onclick procedure TfrmMovimientos.btnDepositoClick(Sender: Tobject); var deposito:Single; begin If edMonto.Text=’’ Then begin Showmessage(‘Ingrese monto del movimiento...’); Exit; end; deposito := strtofloat(edMonto.Text); td := td + deposito; cd := cd + 1; lblCantDeposito.caption := inttostr(cd); lblTotalDeposito.caption := floattostr(td); saldo := strtofloat(lblSaldo.caption); lblSaldo.caption:= floattostr(saldo + deposito); edMonto.text :=’’; edMonto.SetFocus; Docente: Lic. José Luis Ponce Segura www.vigilvirtual.com Prac03 (3 de 7)
    4. I.S.T. “F.P.G.V.” Computación e Informática Programación Distribuida y Concurrente end; Objeto: btnRetiro Evento: Onclick procedure TfrmMovimientos.btnRetiroClick(Sender: Tobject); var retiro:Single; begin if edMonto.text=’’ Then begin showmessage(‘Ingrese monto del movimiento...’); Exit; end; retiro := strtofloat(edMonto.Text); saldo := strtofloat(lblSaldo.caption); If saldo < retiro Then begin Showmessage(‘La cantidad excede su saldo actual’); edMonto.Text:=’’; edMonto.setFocus; end Else begin tr := tr – retiro; cr := cr + 1 ; lblCantRetiro.caption := inttostr(cr) ; lblTotalRetiro.caption := floattostr(tr) ; lblSaldo.caption := floattostr(saldo – retiro) ; End; edMonto.clear; edMonto.setfocus; end; Objeto: btnNuevo Evento: OnClick procedure TfrmMovimientos.btnNuevoClick(Sender: Tobject); begin limpiar; edcliente.SetFocus; end; Objeto: btnSalir Evento: Onclick procedure TfrmMovimientos.btnSalirClick(Sender: Tobject); begin close; end; Objeto: frmMovimientos Evento: OnClose procedure TfrmMovimientos.FormClose(Sender: Tobject; var Action: TcloseAction); begin If MessageDlg (‘¿Desea Salir de la Aplicación?’, mtConfirmation ,[mbyes,mbno],0) = mrNo Then Begin // Si ha respondido No action:=caNone; end; end; Docente: Lic. José Luis Ponce Segura www.vigilvirtual.com Prac03 (4 de 7)
    5. I.S.T. “F.P.G.V.” Computación e Informática Programación Distribuida y Concurrente 1.4 CREACIÓN DE LA UNIDAD DE CÓDIGO DELPHI “MÓDULO” (ListBox.pas) a) En el formulario inserte los controles necesarios y establezca las propiedades necesarias para obtener la siguiente apariencia: b) Ahora procedemos a establecer la Propiedad (Name) a los siguientes objetos: Objeto Propiedad Valor Asignado Form1 Name FrmListBox ListBox1 Name lstIzquierda ListBox2 Name lstDerecha Button1 Name btnTodoDerecha Button2 Name btnDerecha Button3 Name btnIzquierda Button4 Name btnTodoIzquierda Button5 Name btnAgregarIz Button6 Name btnBorrarIz Button7 Name btnBorrarTodoIz Button8 Name btnAgregarDe Button9 Name btnBorrarDe Button10 Name btnBorrarTodoDe NOTA: establezca las demás propiedades que usted crea conveniente. c) Ahora proceda a escribir el código correspondiente: Declare la variable op según se observa a continuación: Objeto: frmListBox Evento: OnCreate procedure TfrmListbox.FormCreate(Sender: Tobject); begin lstderecha.Sorted:=true; end; Docente: Lic. José Luis Ponce Segura www.vigilvirtual.com Prac03 (5 de 7)
    6. I.S.T. “F.P.G.V.” Computación e Informática Programación Distribuida y Concurrente Procedimiento creado por el Usuario Procedure TfrmListbox.MoverItems; var i:Integer; m,t:String; Begin m:=’NO Items’; Case op of 1: Begin If lstizquierda.Items.Count = 0 Then begin Showmessage(m); Exit; end; For i:= 0 To lstIzquierda.Items.Count – 1 do begin lstDerecha.Items.Add(lstIzquierda.Items.Strings[i]); end; lstizquierda.items.clear; end; 2: Begin If lstIzquierda.itemindex=-1 then begin Showmessage(m); Exit; end; lstderecha.items.add(lstizquierda.items.strings[lstizquierda.itemindex]); lstizquierda.items.Delete(lstizquierda.itemindex); end; 3: Begin // ahora hágalo Usted end; 4: Begin // ahora hágalo Usted end; end; end; Ahora deberá establecer el procedimiento recientemente creado en el Area Type Type TfrmListBox = class(Tform) XXXXXX; YYYYYY; ZZZZZZ; procedure MoverItems; // Sólo agregue ésta línea Objeto: btnTodoDerecha Evento: OnClick procedure TfrmListbox.btnTodoDerechaClick(Sender: Tobject); begin op:=1; MoverItems; end; Objeto: btnDerecha Evento: Onclick procedure TfrmListbox.btnDerechaClick(Sender: Tobject); begin op:=2; MoverItems; end; Docente: Lic. José Luis Ponce Segura www.vigilvirtual.com Prac03 (6 de 7)
    7. I.S.T. “F.P.G.V.” Computación e Informática Programación Distribuida y Concurrente Objeto: btnIzquierda Evento: Onclick procedure TfrmListbox.btnIzquierdaClick(Sender: TObject); begin op:=3; MoverItems; end; Objeto: btnTodoIzquierda Evento: OnClick procedure TfrmListbox.btnTodoIzquierdaClick(Sender: TObject); begin op:=4; MoverItems; end; Objeto: btnAgregarIz Evento: Onclick procedure TfrmListbox.btnAgregarIzClick(Sender: TObject); var valor:String; begin valor:=InputBox('Item Izquierda','Ingrese Item valor para la Izquierda: ', 'Valor de ejemplo'); lstizquierda.Items.add(valor); end; Objeto: btnBorrarIz Evento: Onclick procedure TfrmListbox.btnBorrarIzClick(Sender: TObject); begin If lstIzquierda.itemindex=-1 then begin Showmessage('Seleccione un item'); Exit; end; lstizquierda.Items.Delete(lstizquierda.itemindex); end; Objeto: btnBorrarTodoIz Evento: OnClick procedure TfrmListbox.btnBorrarTodoIzClick(Sender: TObject); begin lstizquierda.items.Clear; end; TAREA ENCARGADA: • Para el formulario FrmMovimientos, haga los cambios necesarios para que muestre un resumen de los depósitos y retiros (número y cantidad). • Para el formulario frmListBox, realice el procedimiento respectivo para que compare las dos listas y muestre los ítems repetidos (índice y texto). • Realice una aplicación que permita ingresar código, apellidos, nombres, edad, colegio (A, B, C), sexo, edad, nota. Luego deberá calcular los siguiente: Número de Alumnos por Sexo Masculino y Femenino. Número de alumnos por Colegio A, B y C. Promedio de Edad General, por Colegio y por Sexo Promedio de Notas General, por Colegio y por Sexo. • En función a los ejercicios de la presente práctica donde se utiliza la estructura repetitiva FOR, Usted deberá reemplazarlos por WHILE DO y REPEAT UNTIL según corresponda. Docente: Lic. José Luis Ponce Segura www.vigilvirtual.com Prac03 (7 de 7)
    SlideShare Zeitgeist 2009

    + Jose PonceJose Ponce Nominate

    custom

    135 views, 0 favs, 0 embeds more stats

    Guías de Laboratorio de programación con Delphi, more

    More info about this document

    © All Rights Reserved

    Go to text version

    • Total Views 135
      • 135 on SlideShare
      • 0 from embeds
    • Comments 0
    • Favorites 0
    • Downloads 8
    Most viewed embeds

    more

    All embeds

    less

    Flagged as inappropriate Flag as inappropriate
    Flag as inappropriate

    Select your reason for flagging this presentation as inappropriate. If needed, use the feedback form to let us know more details.

    Cancel
    File a copyright complaint
    Having problems? Go to our helpdesk?

    Categories