60 likes | 174 Views
CS 240 – Computer Programming I Lab . Kalpa Gunaratna – kalpa@knoesis.org http://knoesis.wright.edu/researchers/kalpa/. Contact . Contact by e-mail kalpa@knoesis.org Office hours 376 Joshi Mondays & Wednesday 3:00 pm – 4:00 pm. Methods.
E N D
CS 240 – Computer Programming ILab KalpaGunaratna – kalpa@knoesis.org http://knoesis.wright.edu/researchers/kalpa/
Contact • Contact by e-mail • kalpa@knoesis.org • Office hours • 376 Joshi • Mondays & Wednesday 3:00 pm – 4:00 pm
Methods • <access modifier> <return type> <method name>(<parameters>){ } • Example: • private intgetAge() { return <something of int type>; } The above method returns an int value and some int value should be returned.
Example : public static void doCalc() { body } Since above method is of type “void” it does not return anything. Because it is “static” you can directly call it from anywhere using the class name it belongs to. If the class it belongs to is Calculations, it can be called by Calculations.doCalc(); .
In Lab • Do the lab having one method to get user input for the size of the shae.
Post Lab • Use methods to get user input for the character to print the shapes. • Please follow the grading scheme when you do post labs and projects.