This project is based on exercises in the text. To the extent that instructions here differ from those in the text, the instructions on these web pages take precedence. |
JPanel
like class Shapes (Fig. 5.26) on page 192.
int
parameter, and sets the value of the instance
variable to the value of this parameter.
public void paintComponent(Graphics g)
to draw the specified
number of ovals as concentric rings. All ovals should be centered in the panel.
The smallest oval should have width and height equal to getWidth()
and
getHeight()
, respectively divided by the total number of ovals. The largest oval should
touch the edges of the window, and remaining ovals should be equally spaced between these
two extremes.
double
values for accuracy,
and results converted to int
for passing to the drawOval()
method.
Enter triangle size: 5 Enter character: + + +++++ +++++ + ++ ++++ ++++ ++ +++ +++ +++ +++ ++++ ++ ++ ++++ +++++ + + +++++
+
in the example above) as a
char
, use the String
method charAt(0)
to extract the first
character of the user's input:
input.next().charAt(0)
// gets first char
from Scanner
object named input