You Might Proceed in This Manner
You Might Proceed in This Manner
1
1
2
2
change point 1
change point 2
report length
report equation
**there are many more behaviors that a
Line could have .. Well keep it simple
UML (unified
modeling language)
is a language of
diagrams, which
can be used to
describe a design.
A UML class
diagram has 3
parts:
Each object created from this class (each instance) gets its
own copy of this variable.
Private indicates that this class member is not accessible from
other classes
Initial values may be provided for instance variables, which
are stored prior to the execution of constructor statements.
A slope method must be added to this class for this method to function
properly.
Access
public class LineApp{
//create a Line, change its position, report its length and output its position
public static void main (String [] args){
Line myline = new Line( 2,2,6,7);
NOTE: it would be illegal to try to access instance variables from this class !!
myline.xcoord1 = 1;
//error
myline.ycoord1 = 2;
//error
System.out.println(The length of my line is + myline.length();
System.out.println(The line is: + myline.equation();
}
}
The instance data is ENCAPSULATED by the object!!!! This preserves
the integrity of the data!!
Variable Types