Hello,
The comments in the code are my specified questions about the code. Please help me with finding the proper solution. I searched on the web, but I did not find the right solution for my problem. I couldn't find the right way to implement the information I found on the internet. So that's why I need some people who have more experience with Java who are willing to help me.
Could you help me please?
This is my code (with comments/questions):
import java.util.Scanner; import java.util.ArrayList; class Bank{ double balance; //Account account; ArrayList<Account>account = new ArrayList<Account>(); CommandReader commandReader; Bank(){ commandReader = new CommandReader(); } void run(){ commandReader.run(); // The commandReader is a class which already should be fine } void enroll(String name){ if(account.equals(account)){ //Why is this always true? I doesn't want to create two of the same accounts. In the commandReader the input is enroll Name System.out.println("already enrolled"); } else { account.add(account); //This does also not work properly! when enroll Name is typed in by the user, there should be enrolled an account with name = Name and balance = 0 } } void print(String name){ if(account.equals(account)){ System.out.println("Account of "+name); System.out.println(" balance: "+balance); } else { System.out.println("no such name "+name); } } void printAll(){ if(account.equals(account)){ System.out.println(account); //What I want to print here are all the accounts and they should be printed the same as the method above prints the accounts } } public static void main(String[] args){ new Bank().run(); } } class Account{ double balance; String name; Account(){ bank = new Bank(); //Is this necessary? } void user(String name, double balance){ this.name = name; this.balance = balance; //I think I don't understand it yet. The name and balance is what I want to store of the accounts } }