Hi there. I've been working on a side project outside of class (I'm a Software Engineering student at Uni) which is really just a simple Banking system to help my understanding of Java. Basically the program reads existing accounts from a .txt file which are then placed into an ArrayList (they are split into Account objects).
The user can then choose to create a new account which added to the ArrayList or edit an existing one. I have three classes - the main class, Account class and UserInterface class. The main class holds all the methods such as SaveAccount (writes the accounts into file) etc. the Account class defines the account and then the UserInterface produces a UI to the user and interacts with them. The problem is I have the ArrayList in the main class and the only way to access it in UserInface is through making it public. My lecturer said this is bad since then the UserInterface class can edit it which I don't want. The thing is though I can't make the Account methods private as I want to edit them until they are put into the ArrayList so I'm not sure how to do it.
My only theory is copying the object to a duplicate class which has private settings before throwing it into the ArrayList. Would this work/be the best solution? Sorry if my question is long winded, I'll try to make it more concise if necessary.
P.S I wasn't sure if this should go in theory as I'm not posting code but it sort of addresses ArrayLists directly