22 7_RandomCircle_Easy - agarmstrong21/agarmstrong_swd_2019 GitHub Wiki

22-7_RandomCircle_Easy

Portfolio Home Page

Problem Statement

(Display a Circle and Its Attributes) Write a program that displays a circle of random size and calculates and displays he area, radius, diameter, and circumference. Use the following equations: diameter = 2 x radius, area = pi x radius^2, circumference = 2 x pi x radius. Use the constant Math.PI for pi. Al drawing should be done on a subclass of JPanel, and the results of the calculations should be displayed in a read-only JTextArea.

User Documentation

RandomCircle creates a GUI to show off a randomly sized and generated circle. This circle has a random radius and the program calculate the circumference, area, and distance, and post them below the circle to let the user see the dimensions.

Developer Documentation

RandomCircleDriver creates a new RandomCircle object which in turns creates a new GUI window with the random circle displayed. The program automatically randomly generates the radius using the Random java tools. Then, the radius is used in the circumference, diameter, and area methods to return the respective values into final doubles. After that, the program will create the window with a BorderLayout JFrame. The top will contain the randomly generated circle using the paint method. Afterwards, the circumference, area, radius, and diameter are presented in a AreaField below.

image

Java Docs

The java documents are served from a local web server on this machine. To start the web server, navigate to the directory immediately above where the source code is checked out (i.e. ~/git ) and then use "python -m SimpleHTTPServer" in that directory.

cd ~/git python -m SimpleHTTPServer&

Note: if you are running python 3 (which you can check via opening a terminal and typing: python --version), then the command is:

python3 -m http.server

Java Docs for 22-7_RandomCircle_Easy

Source Code

Source Code for 22-7_RandomCircle_Easy