You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by df...@apache.org on 2004/10/17 19:03:56 UTC
cvs commit: jakarta-commons-sandbox/contract/xdocs/style project.css project-colburne.css maven.css tigris.css print.css
dflorey 2004/10/17 10:03:56
Modified: contract/xdocs quickstart.xml
Removed: contract/xdocs/style project.css project-colburne.css
maven.css tigris.css print.css
Log:
Removed styles
Revision Changes Path
1.3 +9 -2 jakarta-commons-sandbox/contract/xdocs/quickstart.xml
Index: quickstart.xml
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/contract/xdocs/quickstart.xml,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- quickstart.xml 15 Oct 2004 17:57:27 -0000 1.2
+++ quickstart.xml 17 Oct 2004 17:03:56 -0000 1.3
@@ -19,8 +19,11 @@
a contract that defines which types of parameters are accepted by your method and you specify the
type of tbe return value. This is how a method might look like that calcalutes speed:</p>
<source>
- public float calculateSpeed(float distance, float time, String unit) {
- ...calculate speed...
+ public float calculateSpeed(float distance, float time, String timeUnit) {
+ float speed;
+ if (timeUnit.equals("s")) speed = distance / time;
+ else if (timeUnit.equals("min")) speed = distance*60 / time;
+ else speed = distance*3600 / time;
return speed;
}
</source>
@@ -84,6 +87,10 @@
}
}
</source>
+<p>You'll be shocked at this moment as you have to write down a lot more lines
+ of code than in the classical java method example. But on the other hand you'll gain
+ a lot! Launch the example that is included in this component by invoking the contrac-example.jar:</p>
+ <source>java -jar contract-example.jar</source>
<p>As you can see, you have to define constraints for all the parameters that your method will accept.
You even have the possibility to provide a default value that will be used when no parameter value
is provided. This means, that the parameter is optional.</p>
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org