Byron's CSC212 Web Site

CS1 at Oswego

Hypertexknowlogy

Frequently Asked Questions

 
Byron's CSC212 Web Site  
 
 
 
Class Notes

Wednesday September 27 , 2000
 
Polygon Worm Program and Application Architecture  

 
  Class Notes  -- Wednesday September 27 , 2000

   
   CSC212 - September 27, 2000
   ======================================
  
   Lecture Topic: APPLICATION ARCHITECTURE
  
   DEF: An APPLICATION is a Java class containing a public
        static method called "main".
  
   DEF: An APPLICATION ARCHITECTURE is a set of conventions
        regarding the components of an application and the 
        communication among these components.
  
   Problem: 4 ways to solve the same problem
  
    A line of "N" congruent squares collectively has 
    area "a". What is the perimeter of the line of squares. 
                ___________
    Example 1  |___|___|___|   a = 75, n =3
  
       area of one Square  = 25
       sq rt of one Square =  5
       8 sides x 5         = 40
  
   The Basic Applicaion Architecture
  
   DEF: BASIC APPLICATION ARCHITECTURE is the application 
        architecture in which the application class
        contains precisely one thing, the main method.
  
    The Java Program
  
      <?Class>  LineOfSquaresBAA   // BAA = Basic Appl Arch
  
      <?Program>
  
       class LineOfSquaresBAA
    {
       static public void main (String args)
     {
       // The Program 
  
       // Declare some variables
  
       int    nrSquares;
       double figureArea;
       double squareArea;
       double squareSideLength;
       int    eeCount;              // External Edges
       double perimeter;
  
    // Read the Total Area
    // Read the Data
  
       nrSquares = IO.read_int();
       figureArea = IO.read_double();
  
    // Compute the 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 the perimeter
  
       perimeter = eeCount * squareSide;
  
    // Display the Result
  
       Io.println("Perimeter = " + perimeter);
  
   =========================================================
   123456789112345678921234567893123456789412345678951234567