Bargains With Evil
From Huben's Wiki
(→Read The Contract Carefully!) |
(→Read The Contract Carefully!) |
||
Line 44: | Line 44: | ||
A method call sets argument variables in the method. In the Innocent.main() call to Evil.bargain(), Evil.bargain()'s whatIsGiven argument is set to the String "honor". | A method call sets argument variables in the method. In the Innocent.main() call to Evil.bargain(), Evil.bargain()'s whatIsGiven argument is set to the String "honor". | ||
− | Methods can return a single value, which can be placed in a variable, used, or ignored. A method returns a value using the '''return''' reserved word, as you see at the end of both methods of Evil. If the return type of a method is '''void''', no value is returned and there is no need for a return statement. Evil.bargain() returns a | + | Methods can return a single value, which can be placed in a variable, used, or ignored. A method returns a value using the '''return''' reserved word, as you see at the end of both methods of Evil. If the return type of a method is '''void''', no value is returned and there is no need for a return statement. Evil.bargain() returns a String with the value "despair" to Innocent.main(), which places that value into the String named 'result'. |
Arguments and returns can be any types or combination of types. | Arguments and returns can be any types or combination of types. |