*
The moose likes OO, Patterns, UML and Refactoring and the fly likes UML and Variables Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Engineering » OO, Patterns, UML and Refactoring
Bookmark "UML and Variables" Watch "UML and Variables" New topic
Author

UML and Variables

Rykurex Peters
Greenhorn

Joined: Oct 28, 2012
Posts: 21
Hello again everybody, just like to say thanks for the help I've gotten so far! Now, onto the problem at hand, I'm designing a program to calculate the following when a ladder is placed perpendicularly to a wall (at a right angle)

the angle between the ladder and the ground (bottomAngle);
the length of the ladder (ladderLength);
the distance of the bottom of the ladder to the wall (floorLength); and
how long it would take an object to reach the floor if dropped from the top of the ladder (dropTime)

My question is, in the UML, do I have to declare everything I am finding as a varialbe/(field, as I've seen it called sometimes??)
topAngle and verticalHeight are going to be user input, and valueGravity is constant
Is this everything I need to include, because everything else is being calculated, but is NOT being used in itself, to calculate another value?

RATriangle
________________
-verticalHeight
-topAngle
-valueGravity
________________
-bottomAngle
-ladderLength
-floorLength
-dropTime
+getBottomAngle
+getLadderLength
+getFloorLength
+getDropTime

Or do I also need to include bottomAngle, ladderLength etc etc?

Thanks guys <3
Junilu Lacar
Bartender

Joined: Feb 26, 2001
Posts: 4446
    
    5

A few things:
1. A right angle is, by definition, exactly 90 degrees.
2. Assuming the wall is a normal, perfectly vertical wall, then a ladder placed perpendicular to it would be perfectly horizontal.
3. I don't see a use for a UML diagram here but if it's for school, you should ask your teacher for clarification. I suspect you don't need to include intermediate variables.
4. Do the calculations by hand first, then translate the calculation process into code.


Junilu - [How to Ask Questions] [How to Answer Questions]
Winston Gutkowski
Bartender

Joined: Mar 17, 2011
Posts: 7552
    
  18

Rykurex Peters wrote:Now, onto the problem at hand, I'm designing a program to calculate the following when a ladder is placed perpendicularly to a wall (at a right angle)

Just to add to Junlu's good advice, there are usually only 2 things you need to construct a right-angle triangle:
1. Theta (the angle between hypotenuse and base), plus the length of any known side, or
2. The length of any two known sides.
And you've been given the latter. Everything else can be derived, so there's no need to store anything more.

Winston


Isn't it funny how there's always time and money enough to do it WRONG?
Articles by Winston can be found here
Kemal Sokolovic
Bartender

Joined: Jun 19, 2010
Posts: 825
    
    5

My question is, in the UML, do I have to declare everything I am finding as a varialbe/(field, as I've seen it called sometimes??)

Your UML class diagram should contain all the class fields. Local variables (that you use inside your methods) should not be in UML class diagram.

E.g., if you're calculating dropTime in some method, the method should be in UML diagram, but the variable dropTime should not.


The quieter you are, the more you are able to hear.
Rykurex Peters
Greenhorn

Joined: Oct 28, 2012
Posts: 21
My apologies, I typed something then deleted it, then didn't read over my sentence again. I meant the floor is perpendicular to the wall, there's no point in putting a ladder on the ground now is there :P?
Thanks to you all, I understand it now, I think my UML code is correct going by what Kemal said and thanks for the extra tip of working everything out by hand first, it'll certainly be useful for testing
Kemal Sokolovic
Bartender

Joined: Jun 19, 2010
Posts: 825
    
    5

Glad we could help!

Also, I think this might be a topic for OO, Patterns, UML and Refactoring forum, but that's up for someone with higher rank to decide.
 
Don't get me started about those stupid light bulbs.
 
subject: UML and Variables
 
Similar Threads
astrology/numerology
Lightweight vs. Heavyweight objects
MVC form action problem
Factory Home Questions
Renovating career from Developement to management