0% found this document useful (0 votes)
50 views2 pages

El Main

This document contains code for an Android application that allows a user to enter a number using buttons, then displays the breakdown of banknotes needed to withdraw that amount. It includes methods to add numbers to a display string, clear the display, calculate the banknote amounts, and show an error dialog if the amount entered is invalid.

Uploaded by

SHANG
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
50 views2 pages

El Main

This document contains code for an Android application that allows a user to enter a number using buttons, then displays the breakdown of banknotes needed to withdraw that amount. It includes methods to add numbers to a display string, clear the display, calculate the banknote amounts, and show an error dialog if the amount entered is invalid.

Uploaded by

SHANG
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

String display = "";

@Override
public void onClick(View view) {
int total, t500 = 0, t200 = 0, t100 = 0, t50 = 0, t20=0;
boolean ret;

switch (view.getId()){
case R.id.Btn1:
display += "1";
LblDisplay.setText(display);
break;
case R.id.Btn2:
display += "2";
LblDisplay.setText(display);
break;
case R.id.Btn3:
display += "3";
LblDisplay.setText(display);
break;
case R.id.Btn4:
display += "4";
LblDisplay.setText(display);
break;
case R.id.Btn5:
display += "5";
LblDisplay.setText(display);
break;
case R.id.Btn6:
display += "6";
LblDisplay.setText(display);
break;
case R.id.Btn7:
display += "7";
LblDisplay.setText(display);
break;
case R.id.Btn8:
display += "8";
LblDisplay.setText(display);
break;
case R.id.Btn9:
display += "9";
LblDisplay.setText(display);
break;
case R.id.Btn0:
display += "0";
LblDisplay.setText(display);
break;
case R.id.BtnBorrar:
borrarDisplay();
break;
case R.id.BtnRetirar:
total = Integer.parseInt(LblDisplay.getText().toString());
t500 = ClsBilletes.TotalBill500(total);
t200 = ClsBilletes.TotalBill200();
t100 = ClsBilletes.TotalBill100();
t50 = ClsBilletes.TotalBill50();
t20 = ClsBilletes.TotalBill20();
borrarDisplay();
ret = ClsBilletes.control(total);
if(ret){
nRetiro();
}
break;
}
LblBilletes500.setText(""+t500);
LblBilletes200.setText(""+t200);
LblBilletes100.setText(""+t100);
LblBilletes50.setText(""+t50);
LblBilletes20.setText(""+t20);
}

public void borrarDisplay(){


display = "";
LblDisplay.setText("0");
}

public void nRetiro(){


CharSequence [] opciones = {"Aceptar", "Cancelar"};
AlertDialog.Builder ventana = new AlertDialog.Builder(this);
ventana.setTitle("Cantidad no disponible\nImporte maximo admitido "+
ClsBilletes.tDinero);
ventana.setItems(opciones, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
if(opciones[i].equals("Aceptar")){
borrarTodo();
}
}
});
ventana.show();
}

public void borrarTodo(){


display = "";
LblDisplay.setText("0");
LblBilletes500.setText("0");
LblBilletes200.setText("0");
LblBilletes100.setText("0");
LblBilletes50.setText("0");
LblBilletes20.setText("0");
}
}

You might also like