I am currently working on an assignment where we have to make a class that encapsulates a person’s name in such a way that a program will run off it. Now, if it was just 2 classes I could get it to work fine, but the main program creates multiple objects, and these new objects are supposed to refer to one another for information. And this I am not sure how to do.
For example, the first part of the program creates the object newName, and then has one enter information defining the variables FirstName, MiddleName, and LastName.
Then it creates the object myName. At this point it is supposed to access the previous class, obtain the variable values from there, store them in the new class, and print them out. And, like I said, it's accessing the other class that I'm not sure how to do.
The Line in question:
Name myName = new Name(newName.getFirstName(), newName.getMiddleName(), newName.getLastName());
Edit: and now I realize I screwed up the title. Probably means I should get to sleep sooner rather than later.