Reputation: 35
My professor gave us this program but did not explain UML to us at all and I am wondering if I have made this diagram correctly.
CODE:
package p1;
public class MyProg {
static int i = 5;
private Integer j = new Integer(10);
protected double k = 2.5;
public MyProg() {}
public static void main(String[] args) {
MyProg mp = new MyProg();
}
void m1(){
System.out.println("Hello World!");
}
void m1(String str, int n){
for(int k = 0; k < n; k++)
System.out.println(str);
}
public static int getI(){
return MyProg.i;
}
protected Integer getJ(){
return new Integer(j);
}
double getK(){
return new Double(k);
}
}
Upvotes: 1
Views: 563
Reputation: 12191
I've never been much for being too obsessive about details of UML myself (I've definitely seen design meetings that descended into discussions of the finer points of UML rather than about the design itself), but a few minor points:
double getK()
) are missing access modifiers. While it's technically syntactically legal to rely on the defaults, it's always better to be explicit about your intent.Upvotes: 1
Reputation: 6328
On your diagram:
+ main(in args: String[*])
. Of course underscoredUpvotes: 2
Reputation: 36333
Would be nice to paste all answers in a single one...
Integer
, String
, Double
(as being classes, I guess) and sometimes mix int
while in your class diagram you use all lower case (being primitives) and always integer
. That should be aligned.Upvotes: 0