I have a java class Customer
with constructor as Customer(string firstName, string lastName)
and a getName()
method that allow me to get the customer name from each Customer
object
Then I have an input.txt
file with first names and last names by lines as below example:
Alan, Walker
Tom, Hanks
How can I automatically read the first name and last name from each line above, and correspondingly create a Customer
object for that person name?
Example: I want to the program to automatically read the first line "Alan, Walker" and create the object AlanWalker = new Customer("Alan", "Walker")
, then do the same for 2nd line
Secondly, my 2nd task is to provide the user ability to give command from keyboard to get the name of the customer created. For example: the user can type "Alan Walker, print name" and the program will run AlanWalker.getName()
to give the desired output as "Alan Walker". How can I implement this?