Results 1 to 11 of 11
  1. #1
    Monochii is offline Member
    Join Date
    Apr 2012
    Posts
    4
    Rep Power
    0

    Post wind angle correction calculator help

    I need help trying create an interface for the wind angle correction calculator I know what im doing wrong but I just cant seem fix it, I already emailed my prof but he hasnt even reply and it's been 2 days already. Yes, its a homework problem but it seems difficult.
    Also where it says "E6B e6b = new E6B( int dc, int vt, int wd, int vw);" thats the problem and the error is "error: '.class' expected. Do I just add something like public class or something? One more thing, anything with the // that I havent filled out yet, any hints on what I should do?

    Here is what I've already did so far:

    import java.awt.*; // specifies how components are arranged
    import javax.swing.*;
    import java.awt.event.*;

    public class E6BComputer extends JFrame implements ActionListener
    {
    private JLabel slblDC, slblWD, slblVT, slblVW, slblDA, lblDeltaA;
    private JButton btnCalcDeltaA;
    private JTextField tfDC, tfWD, tfVT, tfVW;

    public E6BComputer()
    {
    super( "E6B Computer Wind Correction" );
    setLayout( new GridLayout(5,2) ); // set frame layout

    slblDC = new JLabel("desired course");
    add( slblDC );

    tfDC = new JTextField("0");
    add( tfDC );


    slblDA = new JLabel("delta a");
    add( slblDA );

    lblDeltaA = new JLabel("0");
    add(lblDeltaA);


    // Create remaining labels and textfields

    slblDC = new JLabel("desired course");
    add( slblDC );

    tfDC = new JTextField("0");
    add( tfDC );


    slblWD = new JLabel("Wind Direction");
    add( slblWD );

    tfWD = new JTextField("0");
    add(tfWD);

    // Create JButton

    btnCalcDeltaA = new JButton("Get Angle");
    add( btnCalcDeltaA );

    // add action listener to JButton

    btnCalcDeltaA.addActionListener( this );

    setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
    setSize( 275, 400 ); // set frame size
    setVisible( true );
    }

    public void actionPerformed(ActionEvent e)
    {
    int dc = Integer.parseInt(tfDC.getText() );
    int wd = 0;
    int vt = 0;
    int vw = 0;
    // instantiate the e6b model, send it the info from the text fields

    // public E6B (int dc, int vt, int wd, int vw)

    E6B e6b = new E6B( int dc, int vt, int wd, int vw);

    // get the wind correction angle

    // public int deltaA()

    int da = e6b.deltaA();

    // put it in the wind correction label

    lblDeltaA.setText( Intege.toString( da ) );
    }

    public static void main(String[] args)
    {
    E6BComputer e6bView = new E6BComputer();
    }
    }

  2. #2
    shall is offline Senior Member
    Join Date
    Apr 2012
    Posts
    199
    Rep Power
    0

    Default Re: wind angle correction calculator help

    yes, create a class E6B in another file called E6B.class. Put both files in the same directory.

    Also, what IDE are you working with, i.e. Netbeans, Eclipse or etc. I'm working with Netbeans and I find it very easy to use - much easier than Eclipse.

    If you want the program to just display the window for now, comment out all code in the actionPerformed function.

  3. #3
    shall is offline Senior Member
    Join Date
    Apr 2012
    Posts
    199
    Rep Power
    0

    Default Re: wind angle correction calculator help

    The Netbean IDE is located at http://netbeans.org/downloads/index.html. Just download the one under the "all" column.

    You'll be able to automatically format your code using alt-shift-f and the IDE will put little light bulbs next to the lines that have problems. right clicking on the lightbulbs will "most of the time" give you the option to auto-correct the problem. I'm pretty impressed with the IDE.

  4. #4
    Monochii is offline Member
    Join Date
    Apr 2012
    Posts
    4
    Rep Power
    0

    Default Re: wind angle correction calculator help

    Quote Originally Posted by shall View Post
    yes, create a class E6B in another file called E6B.class. Put both files in the same directory.

    Also, what IDE are you working with, i.e. Netbeans, Eclipse or etc. I'm working with Netbeans and I find it very easy to use - much easier than Eclipse.

    If you want the program to just display the window for now, comment out all code in the actionPerformed function.
    I use jGRASP cuz my prof recommend me to use it but I'll try to use Netbeans and see how that goes.

  5. #5
    shall is offline Senior Member
    Join Date
    Apr 2012
    Posts
    199
    Rep Power
    0

    Default Re: wind angle correction calculator help

    Interesting IDE - it lets you do UML diagram and access your code from the diagram. Reminds me of Rational Rose. I'll try it sometime.

    Did you create the class yet?

  6. #6
    Monochii is offline Member
    Join Date
    Apr 2012
    Posts
    4
    Rep Power
    0

    Default Re: wind angle correction calculator help

    class as in the E6B.class, then yes I created it but it seems to compiled it correctly (I think) but from my previous code above Im still getting the same error.

    Here's the E6B.class:

    public class E6B
    {
    private double desiredCourse; // degrees
    private double vTrue; // true airspeed in knots
    private double windDirection; // degrees
    private double vWind; // knots

    public E6B()
    {
    desiredCourse=0;
    vTrue=0;
    windDirection=0;
    vWind=0;
    }

    public E6B( int dc, int vt, int wd, int vw )
    {
    desiredCourse=dc;
    vTrue=vt;
    windDirection=wd;
    vWind=vw;
    }

    //
    //
    //
    public int deltaA()
    {
    return (int) (180/Math.PI * Math.asin( (vWind/vTrue) *
    Math.sin((Math.PI * (windDirection - desiredCourse))/180)));
    }

    public static void main(String[] args)
    {
    // E6B( int dc, int vt, int wd, int vw )
    E6B e6b = new E6B(0, 110, 270, 20);
    System.out.println( e6b.deltaA() );
    }

    }

  7. #7
    shall is offline Senior Member
    Join Date
    Apr 2012
    Posts
    199
    Rep Power
    0

    Default Re: wind angle correction calculator help

    Did you put the EB6 class into a separate file? The E6BComputer class will have the main function and the file that contains the E6B class won't.

    You'll have the correct Intege.toString( da ) to Integer.toString(da).

  8. #8
    Monochii is offline Member
    Join Date
    Apr 2012
    Posts
    4
    Rep Power
    0

    Default Re: wind angle correction calculator help

    Yes, I've put the E6B class in a different file, saved as E6B.Java while E6BComputer class is E6BComputer.java. Sorry Im just a bit confused and lost.

  9. #9
    shall is offline Senior Member
    Join Date
    Apr 2012
    Posts
    199
    Rep Power
    0

    Default Re: wind angle correction calculator help

    In post #6, I noticed main was in the E6B class. You can only have one main. Probably keep main in the E6BComputer class and create the E6B and E6BComputer object in that class.

  10. #10
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,305
    Rep Power
    20

    Default Re: wind angle correction calculator help

    Quote Originally Posted by shall View Post
    You can only have one main.
    Wrong.

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  11. #11
    shall is offline Senior Member
    Join Date
    Apr 2012
    Posts
    199
    Rep Power
    0

    Default Re: wind angle correction calculator help

    Quote Originally Posted by DarrylBurke View Post
    Wrong.

    db
    I was wrong.

    But as stated at Using Multiple Main Classes, the situation of using multiple mains in not usual in stadard Java applications:

    Multiple Main Classes

    NetBeans projects can have more than one main class and it's easy to specify the main class an application should run. This allows a programmer to switch between any number of main classes within the same application. Only the code in one of the main classes will be executed, effectively making each class independent of each other.

    Note: This is not usual in a standard Java application. All it needs is one main class as a starting point for the execution of the code. Remember this is a tip for running multiple code examples within one project.

Similar Threads

  1. Homework - UDP Connection with TCP Error Correction
    By GeekWrath in forum New To Java
    Replies: 0
    Last Post: 03-29-2012, 10:37 PM
  2. To print * in right angle format
    By venkatakrishnan in forum New To Java
    Replies: 9
    Last Post: 07-24-2011, 04:29 PM
  3. Play soundclip and generate"wind" like sound
    By diablo2070 in forum New To Java
    Replies: 5
    Last Post: 03-13-2011, 08:47 PM
  4. calculating the angle between 3 points
    By imorio in forum New To Java
    Replies: 2
    Last Post: 12-24-2010, 08:49 AM
  5. SDK for automatic image correction
    By dererstetorres in forum Advanced Java
    Replies: 0
    Last Post: 09-10-2009, 08:23 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •