get/set methods should be used judiciously. As it is, you could simply make your members public, remove the get/set methods, and the effect would be the same with less code.
Narue
Bad Cop
15,460 posts since Sep 2004
Reputation Points: 6,483
Solved Threads: 1,407
Skill Endorsements: 54
AS Narue says, use get/set judiciously. The greatest power of Java (and any OO programming language that is,) is the ability to 'encapsulate' data (members) to better control how to use that data.
A good example in your above code is if you wish to make the course member 'read-only' you can exclude the set method. This would prevent anyone from making unwanted changes to the course member data. You can still set the course member data internally to the class, but not outside the class (since it would still be a private member variable.)
jerbo
Junior Poster in Training
84 posts since Sep 2004
Reputation Points: 11
Solved Threads: 1
Skill Endorsements: 0
brilliant
that you can't read dates? mwa, not so astonishing.
about Sandwiches99, if you know you're 4 years late... why still post?
stultuske
Industrious Poster
4,382 posts since Jan 2007
Reputation Points: 1,318
Solved Threads: 610
Skill Endorsements: 24
JAnd I love you.
you consider that to be Java related? :D
stultuske
Industrious Poster
4,382 posts since Jan 2007
Reputation Points: 1,318
Solved Threads: 610
Skill Endorsements: 24
ehm... yup, that's bout it ...
except: I don't see a getter, I don't see a setter and I don't see an explanation or a question in your post.
if you have a question about it, it's easier for us to answer it if we know you have a question and if we know what that question is.
stultuske
Industrious Poster
4,382 posts since Jan 2007
Reputation Points: 1,318
Solved Threads: 610
Skill Endorsements: 24
And neither of you guys think it is fishy that nobody with over 10 posts on this forum cares? But that two people with one post each happen to come in this thread and co-sign? Fooled us.
BestJewSinceJC
Posting Maven
2,774 posts since Sep 2008
Reputation Points: 874
Solved Threads: 354
Skill Endorsements: 13
Unless this is already well known from you programmers, removing the get/set methods and making variables public would defeat the purpose of 'Object-Oriented' Programming.
not necessarilly, but you would need a good explanation as to the why of the omission to convince me of it being a good design decision.
For example when creating something where the extra overhead (call stack creation...) of using getters and setters would yield unacceptable performance (think a raytracer or 3D animation package) you might want to have some class members in the core of that system that are called at extremely high rate to be publicly accessible.
jwenting
duckman
8,522 posts since Nov 2004
Reputation Points: 1,656
Solved Threads: 345
Skill Endorsements: 19
Most everything you said above is wrong. You can only implement interfaces not other classes. You can extend other classes in an inheritance hierarchy. Or if you want access to another classes public members you can simply instantiate a new Object of that classtype and then say object.variable
BestJewSinceJC
Posting Maven
2,774 posts since Sep 2008
Reputation Points: 874
Solved Threads: 354
Skill Endorsements: 13