References
- The Java Tutorial Implementing
Methods
- The Java Tutorial Passing
Information into a Method - explains Pass by Value
- Cafe au Lait Java - Java Course Notes Methods
|
Lab06
- Exercise 6.14 Write a method
int integerPower(int base,
int exponent)
that returns the value of baseexponent.
There is a Math.pow()
method in the Java API that does this. Do not use it. The
idea is to write your own method, not call the existing method.
Write an applet that gets values for base
and exponent from
the user using JTextFields, and
calculates the result using your
integerPower() method.
- classname: IntegerPowerApplet
- Exercise 6.18 Write a method
void squareOfAsterisks(int side,
Graphics g)
that displays a solid square of asterisks with side rows and side columns. Write an applet
that uses a JOptionPane
in init() to get a value for side from the
user. Then in paint(), call your
squareOfAsterisks()method to display
the square. You should pass your method both the value for side and the
applet's Graphics object in the argument list.
- classname: SquareOfAsterisksApplet
|