Projector Size Calculation Help


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 3 of 3

Thread: Projector Size Calculation Help

  1. #1
    Join Date
    May 2005
    Posts
    2

    Projector Size Calculation Help

    Hi, I've just programmed a class that should be able to tell me how big I should buy a projector screen for my church, when I try to compile the class though, which will be used in the main method of another application, I get two small errors that I can't figure out.
    Errors:
    • '{' expected at line 7
    • '}' expected at line 68

    Here's the code for your review:

    Code:
    /*John Jelinek IV
     *May 22, 2005
     *projectorSize.java
     */
     
    /* will determine how big the projector screen should be */
    class projectorSize()  // LINE 7
    {
      // NOTE: Rear Projector Screen Means Projector That Projects From Behind The Screen
      private double rearRows;  // distance of rear projector screen to last row of seats
      private double nearRows;  // distance of front projector screen to nearest row of seats
      private double farRows;  // distance of front projector screen to farthest row of seats
    
      /* overloaded constructor that grabs nearRows, farRows, and rearRows in that order */  
      public projectorSize(double frontNear, double frontFar, double rearNear)
      {
        nearRows = frontNear;  // sets nearRows to the value the user has indicated
        farRows = frontFar;  // sets farRows to the value the user has indicated
        rearRows = rearNear;  // sets rearRows to the value the user has indicated
      }
    
      /* returns default projector screen width from current distance */
      public double getDefWidth()
      {
        return nearRows / 2;  // default width of front projector
      }
    
      /* returns alternative projector screen width from current distance */
      public double getAltWidth()
      {
        return farRows / 6;  // alternate width of front projector
      }
    
      /* returns rear projector screen width from current distance */
      public double getRearWidth()
      {
        return rearRows / 8;  // default width of rear projector
      }
    
      /* will determine the height for a 4:3 aspect ratio */
      public double getHeight()
      { return ((getDefWidth() * 3) / 4); }
    
      /* will determine the height for a 4:3 aspect ratio */
      public double getAltHeight()
      { return ((getAltWidth() * 3) / 4); }
    
      /* will determine the height for a 4:3 aspect ratio */
      public double getRearHeight()
      { return ((getRearWidth() * 3) / 4); }
    
      /* will determine the height for a 16:9 aspect ratio */
      public double getWideHeight()
      { return ((getDefWidth() * 9) / 16); }
    
      /* will determine the height for a 16:9 aspect ratio */
      public double getWideAltHeight()
      { return ((getAltWidth() * 9) / 16); }
    
      /* will determine the height for a 16:9 aspect ratio */
      public double getWideRearHeight()
      { return ((getRearWidth() * 9) / 16); }
    
     /* to be messed with after it compiles 
      //overridden toString()
      public String toString(){
        return "Distance of rear projector screen from last row: " + Integer.toString(rearRows);
      }//end overridden toString()
    */
    
    } // LINE 68

  2. #2
    Join Date
    Nov 2004
    Location
    Norway
    Posts
    1,560
    The first line of your class def is wrong, you have written it like a method.
    It should be:

    class projectorSize {
    .
    .
    }

    I recon that will take care of the error at line 68 too.
    eschew obfuscation

  3. #3
    Join Date
    May 2005
    Posts
    2
    thanks a lot, I overlooked that, my mistake :/.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center