My question is similar to:
Creating a variable name using a String value.
But I was hoping to take a different angle on it.
The reason for wanting to name each object is so I can call on the specifically later, and create multiple objects using the same statement. Ideally, this is what I want to work.
String dogName = reader.nextLine();
int legs = reader.nextInt();
char beenFed = reader.nextChar();
new dogName = dog(dogName, legs, fed) `
I know java can't accept the variable as the object name. But suppose I want to create three dogs, "Red", "Blue" and "Jeff", how could I configure it, so that later the user can enter
Red.getLegCount();
Blue.hasBeenFed();
etc.
How else can I create this scenario? If I'm wanting to make many differently named Dog objects, how do I do it? And if it isn't a good idea, what could I do instead?
PS - First post on Stack Overflow. Please guide with etiquette/formatting.