I posted a question earlier for a homework assignment but I have a new question. I am new at this so I appreciate any help I can get and I’m not looking for code but more of an explanation of the steps I need to take to get to my answer.
I’m working on an address book. The user picks a menu 1, 2, or 3. I have a main class, a validation class, a class that declares set and get and a class that handles the IO functions.
I’m just learning classes so please be patient but basically I want to understand how to save the info if the user wants to enter a new person.
I have a setName and getName and a setPhoneNumber and getPhoneNumber in a class I also have the function to save everything written in the IO class that was provided. I don’t understand what saves the information I guess is what I’m saying. Do I need to create a scanner for each line? or How do I send it to the right place?
Do I need to call the whole function that is in the IO class that handles the name and phone number?
if(menuNumber == 2)
{
System.out.println("Enter name: ")
System.out.println("enter phone number: ")
}
Thank you in advance for any help. I’m taking classes online and so far java hasn’t been an easy one. I want to understand it but I’m struggling through this book and my projects have a pretty quick turnaround so I want to learn it but I almost need to stop and ask for someone to break it down for me in english instead of staring at a diagram in a book.
Here is a list of steps:
1) prompt user for value
2) get value, store in local variable
3) create new instance of class that holds data
4) pass locals to setters
If you read this from a file put these steps in a loop. Keep reusing the local variables. If one of your constructors takes a variable you can call that as soon as you get the first piece of data. For example (pseudo code);