Synopsis
This class showed us more Shapes World functionality and how to use them in solving problems. Also introduced were Application Architectures and what they are. In this class, the Basic Application Architecture was introduced and the form it takes on was shown.
|
Enhanced ``Shapes World''
Functionality
< Square > .circumscribingCircle () - > < circle > (circle goes outside the square through the vertexes)
< Square > .inscribingCircle () - > < circle > (circle goes inside circle touching each side)
< Circle > .circumscribingSquare () - > < square > {the square outside the circle}
< Circle > .inscribingSquare () - > < square > (the square inside the circle in a diamond fashion)
< Polygon > .circumscribingCircle () - > < circle > (the circle outside the polygon)
< Polygon > .inscribingCircle () - > < circle) (the circle inside the polygon)
< Circle > .circumscribingPolygon (< int degree >) - > Polygon (the polygon outside of the Polygon of degree n)
< Circle > .inscribingPolygon (< int degree >) - > Polygon (the polygon inside a circle)
|
Ex:
What is the area of the ``ring'' bounded by the inscribing circle and the circumscribing circle of a heptagon of 25.2? (degree 7)
Polygon p = new Polygon (7, 25.2);
Circle ic = p.inscribingCircle ();
Circle cc = p.circumscribingCircle ();
double ringArea = cc.area () - ic.area ();
|
Ex:
What is the area of the hexagon which inscribes a circle of diameter 50?
Circle c = new Circle (50 / 2.0);
Polygon x = c.inscribingPolygon (6);
double a = x.area ();
|
Some notes on Strings
ex:
String animal;
String animal2;
String wierdAnimal = animal1 + animal2;
IO.println (wierAnimal);
The Environment
animal1 - > ``Zebra''
animal2 - > ``Fish''
wierdAnimal - > ``ZebraFish''
To read the string in
String s = IO.readString ();
Application Architectures
Definition
An APPLICAITON is a Java class containing a public static method called ``main''.
Definition
An APPLICATION ARCHITECTURE is a set of conventions regarding the components of an applicaiton and the communication among these components.
Problem
A line of n congruent squares collectively has area a. What is the perimeter of the line of squares?
a = 75 /P =?
The Basic Application Architecture
Definition
The BASIC APPLICATION ARCHITECTURE is the application architecture in which the application class contains precisely one thing, the main method.
The Java
Class > - > LineOfSquaresBAA
Program > - >
class LineOfSquaresBAA
{
static public void main (----)
{
/ /declare vars - establish data dictionary
int nrSquares;
double figureArea;
double squareArea;
double squareSideLength;
int eeCount;
double perimeter;
/ /read the data
nrSquares = IO.read_int ();
figureArea = IO.read_double ();
/ /compute area of a square
squareArea = figureArea /nrSquares;
/ /compute the side length of a square
squareSide = Math.sqrt (squareArea);
/ /compute the number of external edges
eeCount = (2 * nrSquares) + 2;
/ /compute perimeter
perimeter = eeCount * squareSide;
IO.println (perimeter);
|