Hi, this is part of an assignment question and probably something I should know.
I have 2 classes. I have a method in one class that creates an instance of the other class and sets one of its attributes to a certain value. The class that has its attribute set has a getter method for the attribute but no setter method. How can I set the atttribute? Should there be a setter? The question says nothing about writing a setter.
Thanks
Glen
GlenRogers
0
Newbie Poster
Recommended Answers
Jump to PostIf a class has a private attribute, and the developer didn't supply a setter, that means you're not supposed to set it (eg look at the get methods for the String class - you won't find any corresponding set methods because they don't want you to change a String object …
Jump to PostMaybe there's a constructor for that class that takes that value as a parameter???
All 5 Replies
GlenRogers
0
Newbie Poster
JamesCherrill
4,733
Most Valuable Poster
Team Colleague
Featured Poster
GlenRogers
0
Newbie Poster
JamesCherrill
4,733
Most Valuable Poster
Team Colleague
Featured Poster
GlenRogers
0
Newbie Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.