The searchPhoneNumberByName(Person person, String name ) doesn't return anything. It only calls a search method on the Person class and prints the result.
Swastik
Swastik Dey wrote:
The searchPhoneNumberByName(Person person, String name ) doesn't return anything. It only calls a search method on the Person class and prints the result.
The return type of the method is void. What are you trying to return from this method?
I'm stuck here
I can't think about what to do past the following options and none seem correct.
A. Repeat the phone number search I used for #2 rather than have #5's method, searchForAllInformation call searchPhoneNumberByName. But that goes against the whole DRY concept doesn't it?
B. change searchPhoneNumberByName to return a String and handle printing out the results on the UserInterface class? It seems like I should just get rid of the Search class then.
C. change searchPhoneNumberByName to call another method on the Search class to handle the null and empty?
All things are lawful, but not all things are profitable.
Knute Snortum wrote:One of the things I noticed is that you have UI in your Person class. addPhone() shouldn't prompt for or input a phone number, it should just be:
Also, I think UserInterface is doing more than it should be. The actual logic of putting data into Persons and search should be a its own class. Let's call it PersonMaintenance. This class would call UserInterface to print the menu and to prompt and get data. It would contain the logic for searching Persons. The Search class would go away in this model. Whether you call UserInterface to print "not found" or "phone not found" would be in PersonMaintenance. Anything with a System.out.println() or a scanner would be in UserInterface and only there.
Does this structure make sense to you?
Knute Snortum wrote:One of the things I noticed is that you have UI in your Person class. addPhone() shouldn't prompt for or input a phone number, it should just be:
Knute Snortum wrote:
Also, I think UserInterface is doing more than it should be. The actual logic of putting data into Persons and search should be a its own class. Let's call it PersonMaintenance. This class would call UserInterface to print the menu and to prompt and get data. It would contain the logic for searching Persons. The Search class would go away in this model. Whether you call UserInterface to print "not found" or "phone not found" would be in PersonMaintenance. Anything with a System.out.println() or a scanner would be in UserInterface and only there.
Does this structure make sense to you?
Knute Snortum wrote:
Whether you call UserInterface to print "not found" or "phone not found" would be in PersonMaintenance.
All things are lawful, but not all things are profitable.
Knute Snortum wrote:That looks better. You have the UI isolated in a class. But I was thinking that PersonMaintenance would be the class driving the process. That is, it would have the start() method and that would call the printMenuoptions() from UserInterface (you will need an instance of the class unless you make the method static). PersonMaintenance would have the enterMenuOption() method in it and so on. So PersonMaintenance would have all the logic to "maintain" a Person (add a Person, search, etc.) Then printing "not found" or "phone not found" would be calls to UserInterface.
Live ordinary life in an extraordinary way. Details embedded in this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
|