I am in an intro to Java course, and I need to provide a class diagram with my program assignment. I've got the class diagram completed in the way my professor wants it, but my question has to do with access specifications. I have a class for the main program, then a class below it. The main program creates an instance of the lower class. In the lower class I have made all of the fields private and the methods public. In the main class, however, I have never indicated private or public when declaring the variables. If this isn't specified in the source code are the variables public by default? And how do I show these fields in my class diagram (with a '+' for public, a "-" for private, or no access specification at all)?
Thanks in advance for any assistance that anyone may be able to provide!
Comments
Your question seems to be: "How do I represent package public access modifiers in a UML class diagram?" I'm pretty sure + would be the best option since UML doesn't really have a "package public" equivalent.
I suggest that you make those attributes private, though. Making attributes private and get/set methods for them public is a generally recommended programming practice. This will also help to make your code get accurate representation in the UML class diagram using + and -.
Thanks again for your quick response. This forum is a great resource, and I really appreciate it!
This isn't really for you, the UML diagram asker, but the people who may manage the site. The reason I mention here is that I've tried contacting the site administrators but nothing is leading to a fix in the site.
Thanks again for your help!