Skip to content

Commit

Permalink
primer avance MVC con solicitar recarga
Browse files Browse the repository at this point in the history
  • Loading branch information
n1colasf committed Jun 3, 2023
1 parent 3375810 commit 94920f2
Show file tree
Hide file tree
Showing 8 changed files with 146 additions and 177 deletions.
21 changes: 12 additions & 9 deletions ObligatorioDDA/src/controladores/ControladorSolicitarRecargas.java
Original file line number Diff line number Diff line change
@@ -1,31 +1,34 @@
package controladores;

import logica.dominio.Propietario;
import logica.dominio.Recarga;
import logica.observador.Observable;
import logica.observador.Observador;

public class ControladorSolicitarRecargas implements Observador {
private VistasSolicitarRecargas vista;
private VistaSolicitarRecargas vista;
private Propietario propietario;

public ControladorSolicitarRecargas(VistasSolicitarRecargas vista, Propietario propietario) {
public ControladorSolicitarRecargas(VistaSolicitarRecargas vista, Propietario propietario) {
this.vista = vista;
this.propietario = propietario;
propietario.agregarObservador(this);
}

public void mostrar(){
vista.mostrar(propietario.getNombreCompleto(), propietario.getSaldo());
vista.mostrar(propietario);
}

public void solicitarRecarga(int monto){

try {
Recarga r = new Recarga(monto, propietario);
propietario.agregarRecarga(r);
}
catch (Exception e) {

}
}






@Override
public void actualizar(Object evento, Observable origen) {

Expand Down
11 changes: 11 additions & 0 deletions ObligatorioDDA/src/controladores/VistaSolicitarRecargas.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package controladores;

import logica.dominio.Propietario;

public interface VistaSolicitarRecargas {

void mostrar(Propietario propietario);

void solicitarRecarga(int monto);

}
6 changes: 0 additions & 6 deletions ObligatorioDDA/src/controladores/VistasSolicitarRecargas.java

This file was deleted.

4 changes: 4 additions & 0 deletions ObligatorioDDA/src/logica/dominio/Propietario.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,8 @@ public void crearVehiculo(String matricula, String modelo, String color,
vehiculos.add(vehiculo);
}
}

public void agregarRecarga(Recarga r) {
recargas.add(r);
}
}
6 changes: 5 additions & 1 deletion ObligatorioDDA/src/ui/prop/LoginProp.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,15 @@
*/
package ui.prop;

import logica.dominio.Propietario;

/**
*
* @author Nicolas
*/
public class LoginProp extends javax.swing.JDialog {

private Propietario propietario;

/**
* Creates new form LoginPropietario
Expand Down Expand Up @@ -108,7 +112,7 @@ private void LoginPropPassActionPerformed(java.awt.event.ActionEvent evt) {//GEN

private void LoginPropBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_LoginPropBtnActionPerformed
// TODO add your handling code here:
new TableroControlProp(null, false).setVisible(true);
new TableroControlProp(null, false, propietario).setVisible(true);
}//GEN-LAST:event_LoginPropBtnActionPerformed

/**
Expand Down
46 changes: 23 additions & 23 deletions ObligatorioDDA/src/ui/prop/RecargaProp.form
Original file line number Diff line number Diff line change
Expand Up @@ -26,25 +26,25 @@
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace min="-2" pref="22" max="-2" attributes="0"/>
<Component id="jLabel2" min="-2" max="-2" attributes="0"/>
<Component id="JimgMonto" min="-2" max="-2" attributes="0"/>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<Component id="jLabel13" min="-2" max="-2" attributes="0"/>
<Component id="JSaldo" min="-2" max="-2" attributes="0"/>
<EmptySpace max="32767" attributes="0"/>
<Component id="jLabel1" min="-2" max="-2" attributes="0"/>
<Component id="JImgProp" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="jLabel12" min="-2" pref="144" max="-2" attributes="0"/>
<Component id="JNombre" min="-2" pref="144" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="15" max="-2" attributes="0"/>
</Group>
<Group type="102" attributes="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<Component id="jLabel3" min="-2" max="-2" attributes="0"/>
<Component id="JLabelMonto" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="32" max="-2" attributes="0"/>
<Component id="LoginAdmPass" min="-2" pref="309" max="-2" attributes="0"/>
<Component id="JImputMonto" min="-2" pref="309" max="-2" attributes="0"/>
</Group>
<Component id="LoginAdmBtn" alignment="1" min="-2" pref="455" max="-2" attributes="0"/>
<Component id="JRecargar" alignment="1" min="-2" pref="455" max="-2" attributes="0"/>
</Group>
<EmptySpace pref="17" max="32767" attributes="0"/>
</Group>
Expand All @@ -57,42 +57,42 @@
<Group type="102" alignment="0" attributes="0">
<EmptySpace min="-2" pref="16" max="-2" attributes="0"/>
<Group type="103" groupAlignment="1" attributes="0">
<Component id="jLabel2" alignment="1" min="-2" max="-2" attributes="0"/>
<Component id="JimgMonto" alignment="1" min="-2" max="-2" attributes="0"/>
<Group type="103" alignment="1" groupAlignment="0" attributes="0">
<Component id="jLabel12" alignment="0" min="-2" max="-2" attributes="0"/>
<Component id="jLabel1" alignment="0" min="-2" max="-2" attributes="0"/>
<Component id="jLabel13" min="-2" max="-2" attributes="0"/>
<Component id="JNombre" alignment="0" min="-2" max="-2" attributes="0"/>
<Component id="JImgProp" alignment="0" min="-2" max="-2" attributes="0"/>
<Component id="JSaldo" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
<EmptySpace min="-2" pref="39" max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="jLabel3" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="LoginAdmPass" alignment="3" pref="30" max="32767" attributes="0"/>
<Component id="JLabelMonto" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="JImputMonto" alignment="3" pref="30" max="32767" attributes="0"/>
</Group>
<EmptySpace type="separate" max="-2" attributes="0"/>
<Component id="LoginAdmBtn" min="-2" pref="37" max="-2" attributes="0"/>
<Component id="JRecargar" min="-2" pref="37" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="28" max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Component class="javax.swing.JLabel" name="jLabel13">
<Component class="javax.swing.JLabel" name="JSaldo">
<Properties>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Lucida Grande" size="24" style="1"/>
</Property>
<Property name="text" type="java.lang.String" value="$ 1.877,50"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel2">
<Component class="javax.swing.JLabel" name="JimgMonto">
<Properties>
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
<Image iconType="3" name="/img/money.png"/>
</Property>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel12">
<Component class="javax.swing.JLabel" name="JNombre">
<Properties>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Lucida Grande" size="15" style="0"/>
Expand All @@ -101,29 +101,29 @@
<Property name="text" type="java.lang.String" value="Dar&#xed;o Campalans"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel1">
<Component class="javax.swing.JLabel" name="JImgProp">
<Properties>
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
<Image iconType="3" name="/img/user.png"/>
</Property>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel3">
<Component class="javax.swing.JLabel" name="JLabelMonto">
<Properties>
<Property name="text" type="java.lang.String" value="Monto a recargar: "/>
</Properties>
</Component>
<Component class="javax.swing.JTextField" name="LoginAdmPass">
<Component class="javax.swing.JTextField" name="JImputMonto">
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="LoginAdmPassActionPerformed"/>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="JImputMontoActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JButton" name="LoginAdmBtn">
<Component class="javax.swing.JButton" name="JRecargar">
<Properties>
<Property name="text" type="java.lang.String" value="Recargar"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="LoginAdmBtnActionPerformed"/>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="JRecargarActionPerformed"/>
</Events>
</Component>
</SubComponents>
Expand Down
Loading

0 comments on commit 94920f2

Please sign in to comment.