I am new programming, I learned a few things in C # and then I want to make a menu method to show me the data I fill, but I do not know how to send the data of another method to the Menu () method Maybe I'll explain it, but here's the code
public static void main(String[] args) {
Creacuenta Obj = new Creacuenta();
}
After going to class creacuenta I call the CrearCuenta () method
public class Creacuenta {
public Creacuenta(){
Crearcuenta();
Menu();
}
in the method Create Account () I ask how many accounts to enter, I make a cycle for the full filled all the data and I return a String type string
public String Crearcuenta(){
String Nombre,NombreCuenta="",cadena="";
int Identidad,Tipo,Numcuen,mes;
double DineroIng;
// creo una lista donde se guardaran los datos
Cuenta[] lista = new Cuenta[Numcuen];
// creo un objeto cue donde se almaneceran los datos de cada cuenta
Cuenta cue;
//comienzo el llenado de cada cuenta con un ciclo for
for(int i = 1; i<= Numcuen;i++){
// lleno todos los datos y los envio
cue = new Cuenta(Nombre,DineroIng,Identidad,NombreCuenta);
// lleno la lista
lista[i-1] = cue;
}
// luego hago un ciclo for para crear la cadena
for(int i=0; i<lista.length;i++){
cadena +="\n Cuenta"+(i+1)+ " de :\t "+lista[i].getNombre()+" \n Cedula
: \t"+ lista[i].getId()+ "\ntipo : \t" +lista[i].getTiposcu() +"\n Saldo
actual : \t"+lista[i].getDinero()+"\n /////////////////////////////
";
return cadena}
and in the method Menu () I want to show the data of the chain that returns
public void Menu(){
int Codigo;
Codigo = Integer.parseInt(JOptionPane.showInputDialog("Bienvenido al menu
Digite a donde quieres ir \n 1) Ver Cuenta \n 2) Retirar dinero \n 3)
Salir"));
if(Codigo==1){
JOptionPane.showMessageDialog(null, "Saldo de las cuentas" );
}
and then I do not know what to do to send the data to Menu () and then I try to do this but after finishing the Crearcuenta () method the code run Algo = Crearcuenta () and the data will be filled again.
public class Creacuenta {
public Creacuenta(){
String algo;
Crearcuenta();
algo = Crearcuenta();
Menu(algo);
}
public void Menu(String algo){
In case my question is how can I send the string I made in the Crearcuenta () method to the Menu () method to use it and show it or if it can be made easier , initially the method Crearcuenta () was for the filling of the accounts and did not return anything public void Crearcuenta(){ // hacia lo mismo pero no retornaba la cadena}
but I wanted to make a menu and then I lost a bit