Simple program, but "invalid method dec" at "displayObject(newTriangle)"

Little help would be appreciated. Hopefully a quickie for some of you pros out there. Won't complile as per subject. Just want to view my object. thanks, djason
// For extending the GeometricObject class.
public class Triangle extends GeometricObject{
     private double s1, s2, s3;
     GeometricObject newTriangle=new Triangle(2,3,4);
     displayObject(newTriangle);
     //System.out.println(newTriangle.toString());
     //System.out.println("& " +newTriangle.findArea());
     //Constructor
     public Triangle(double s1, double s2, double s3){
          this.s1=s1;
          this.s2=s2;
          this.s3=s3;
     //Use abstract method findArea from GeometricObject.class
     public double findArea(){
          double s=((s1+s2+s3)/2);
          double b=((s-s1)*(s-s2)*(s-s3));
          double a=Math.sqrt(s*b);
          return a;
     public double findPerimeter(){
          return (s1+s2+s3);          
     static void displayObject(GeometricObject object){
          System.out.println();
          System.out.println(object.toString());          
          System.out.println(object.findArea());
          System.out.println(object.findPerimeter());
}

Sorry- tried to update the "code" ugliness, but too late. This should be more appealing to the eye. Thanks, djason
// For extending the GeometricObject class.
public class Triangle extends GeometricObject{
     private double s1, s2, s3;
     GeometricObject newTriangle=new Triangle(2,3,4);
     displayObject(newTriangle);
     //System.out.println(newTriangle.toString());
     //System.out.println("& " +newTriangle.findArea());
     //Constructor
     public Triangle(double s1, double s2, double s3){
          this.s1=s1;
          this.s2=s2;
          this.s3=s3;
     //Use abstract method findArea from GeometricObject.class
     public double findArea(){
          double s=((s1+s2+s3)/2);
          double b=((s-s1)*(s-s2)*(s-s3));
          double a=Math.sqrt(s*b);
          return a;
     public double findPerimeter(){
          return (s1+s2+s3);          
     static void displayObject(GeometricObject object){
          System.out.println();
          System.out.println(object.toString());          
          System.out.println(object.findArea());
          System.out.println(object.findPerimeter());
}

Similar Messages

  • Simple program but error?

    hi everyone!!
    i am trying to make a simple help file displaying hi and how are you in text area.the compilation gives no error but still i can't run that.can anyone please tell me how to solve my problem of making a simple help screen display...
    import java.io.*;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class Help extends JFrame
    public Help ()
    Container c= getContentPane();
    c.setLayout(new FlowLayout() ) ;
    String val="hi.\n"+"how r u.\n";
    TextArea text= new TextArea( val,20,30);
    add(text);
    setSize(300,300);
    setVisible(true);
    public static void main(String args[])
    Help hm=new Help();
    hm.addWindowListener(
    new WindowAdapter()
    public void WindowClosing(WindowEvent e)
    System.exit(0);
    }

    is this what you mean..its not working..
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class Help extends JFrame
    public Help ()
    Container c= getContentPane();
    c.setLayout(new FlowLayout() ) ;
    String val="hi.\n"+"how r u.\n";
    TextArea text= new TextArea( val,20,30);
    Help.getContentPane().add(text);
    setSize(300,300);
    setVisible(true);
    public static void main(String args[])
    Help hm=new Help();
    hm.addWindowListener(
    new WindowAdapter()
    public void WindowClosing(WindowEvent e)
    System.exit(0);
    }

  • Proc a simple program but got error

    I tried to proc the sample program cppdemo1.pc with the
    following command....
    proc CODE=CPP include=/usr/include/
    include=/opt/SUNWspro/WS6U2/include/CC/Cstd/
    include=/opt/SUNWspro/WS6U2/include/CC/ cppdemo1.pc
    but I got
    INTERNAL ERROR: Failed assertion [PGE Code=90105]
    Segmentation Fault
    WHY???

    A lot longer ago than that. PowerPC apps haven't been supported since Lion, 10.7.x.
    You may have just purchased the game, but the developers obviously haven't kept up to date with the requirements for newer versions of the Mac OS.
    You have three options, depending on how old your Mac is.
    1) If it were ever able to boot directly to Snow Leopard, you could create a separate partition and install SL onto that partition. Make sure to turn on the option during the installation to install Rosetta. That is OS X's PPC emulator.
    2) If your Mac is too new to install Snow Leopard, then you can purchase and install Snow Leopard Server within a VM, such as Parallels, VirtualBox, or Vmware.
    3) Use a separate older Mac for running outdated software.

  • Numbers 09 not working - I can open the program but only a few files are available, missing blank, checklist and many others. e.g  when I click on a file I get this error: The document "nmbtemplate is invalid. The index.xml file is missing. help.

    Please let me know what I can do to get my Numbers (iWork 09) working properly again.
    Here is what is going on:
    Numbers in iWork 09 not working can't access Blank, Checklist and many other files within Numbers.   I can open the program but only a few files are available. When I click on the file (which also has no icon just the name of the file) this warning appears:
    The document "Blank.nmbtemplate" is invalid.  The index.xml file is missing.
    I recently had to get a new hard drive installed and had the system upgraded and more memory put in by a Mac certified specialist recommended to me from the Apple store in Northbrook because this was the 3rd time my drive went bad but this time it was to old (I got the IMAC- in 2007) and the Apple store could no longer work on it this time so they recommended a few places that had certified Mac specialists.  Since then Numbers is not working right.
    I'm sure it's something simple to fix, but I've tried re installing it and that didn't work.  Appreciate any help.
    Thanks
    AppMare

    There is one way its getting fixed. Once I update my Adobe Illustrator CC to Adobe Illustrator CC 2014 it is further allowing me to go into the system folder and allocate the font to the file so that it can replace it. My only concern now is that our MAC partners who will receive these files back from us have Adobe CS6. We will down save it to CS6 but I hope they won't experience any font issues because of us using CC 2014? Any light you can shed on this?

  • Can someone please tell me a simple but effective method for burning a slideshow to DVD? Now that the connection between iPhoto and iDVD no longer exists, I can't figure out a way to get there with an acceptable quality result.

    Can someone please tell me a simple but effective method for burning a slideshow to DVD? Now that the connection between iPhoto and iDVD no longer exists, I can't figure out a way to get there with an acceptable quality result.

    Export the slideshow out of iPhoto as a QT movie file via the Export button in the lower toolbar.  Select Size = Medium or Large.
    Open iDVD, select a theme and drag the exported QT movie file into the open iDVD window being careful to avoid any drop zones.
    Follow this workflow to help assure the best qualty video DVD:
    Once you have the project as you want it save it as a disk image via the File ➙ Save as Disk Image  menu option. This will separate the encoding process from the burn process. 
    To check the encoding mount the disk image, launch DVD Player and play it.  If it plays OK with DVD Player the encoding is good.
    Then burn to disk with Disk Utility or Toast at the slowest speed available (2x-4x) to assure the best burn quality.  Always use top quality media:  Verbatim, Maxell or Taiyo Yuden DVD-R are the most recommended in these forums.
    If iDVD was not preinstalled on your Mac you'll have to obtain it by purchasing a copy of the iLife 09 disk from a 3rd party retailier like Amazon.com: ilife 09: Software or eBay.com.  Why, because iDVD (and iWeb) was discontinued by Apple over a year ago. 
    Why iLife 09 instead of 11?
    If you have to purchase an iLife disc in order to obtain the iDVD application remember that the iLife 11 disc only provides  themes from iDVD 5-7.  The Software Update no longer installs the earlier themes when starting from the iLIfe 11 disk nor do any of the iDVD 7 updaters available from the Apple Downloads website contain them. 
    Currently the only sure fire way to get all themes is to start with the iLife 09 disc:
    This shows the iDVD contents in the iLife 09 disc via Pacifist:
    You then can upgrade from iDVD 7.0.3 to iDVD 7.1.2 via the updaters at the Apple Downloads webpage.
    OT

  • My garageband can't be used because when I open a project (new or old) the program extends beyond the bottom of the display screen and I can't access what is below the bottom of the screen (like the record button).  I know there's a simple fix, but what?

    My garageband can't be used because when I open a project (new or old) the program extends beyond the bottom of the display screen and I can't access what is below the bottom of the screen (like the record button).  I know there's a simple fix, but what?

    two things to try: either click the green "zoom" bottom at the topLeft of the window in the title bar, or go to your System Prefs and then Displays, and increase the resolution that is used

  • My iphone 5 is eligible for battery replacement program but I have bought it from a mobile operator in Thailand (my place) since Dec 2012. Please advice whether I have to contact my operator or Apple Authorized Service Center. And any cost or free?

    My iphone 5 is eligible for battery replacement program but I have bought it from a mobile operator in Thailand (my place) since Dec 2012.
    Please advice whether I have to contact my operator or Apple Authorized Service Center. And any cost or free?

    bsaelao wrote:
    My iphone 5 is eligible for battery replacement program
    How do you know?
    Please advice whether I have to contact my operator or Apple Authorized Service Center. And any cost or free?
    Follow the instructions here -> https://ssl.apple.com/support/iphone5-battery/
    (which is where you should have found out your iPhone is eligible)

  • Error in my simple program

    hey I'm a beginner to java and i tried to program a simple calculator but my Jcreator says it has an Error this is the program that i encoded:
    import javax.swing.JOptionPane;
    public class quiz
         public static void main(String[]args)
              String input;
              double quiz1,quiz2,quiz3,quiz4,quiz5,average;
              input=JOptionPane.showInputDialog("Enter first quiz:");
              Double.parseDouble(input);
              input=JOptionPane.showInputDialog("Enter second quiz:");
              Double.parseDouble(input);
              input=JOptionPane.showInputDialog("Enter third quiz:");
              Double.parseDouble(input);
              input=JOptionPane.showInputDialog("Enter fourth quiz:");
              Double.parseDouble(input);
              input=JOptionPane.showInputDialog("Enter fifth quiz:");
              Double.parseDouble(input);
              average=(quiz1+quiz2+quiz3+quiz4+quiz5)/5
              JOptionPane.showMessageDialog(null,"The average is" +average,"Average",JOptionPane.INFORMATION_MESSAGE);
              System.exit(0);
    }

    shouldn't it be like
    input=JOptionPane.showInputDialog("Enter first quiz:");
    if (input == null) {
                return;
    quiz1 = Double.parseDouble(input); or something like that?
    or else your "quiz" variable don't have any value?
    Edited by: Billwaa on Dec 14, 2008 8:31 AM

  • JMS: simple program (urgent please)

    I am quite new with the JMS. I am trying to have a simple program running in order to start from it towards the application I want to build.
    I tried to run the sample program below:
    package chat;
    import javax.jms.*;
    import javax.naming.*;
    import java.io.*;
    import java.io.InputStreamReader;
    import java.util.Properties;
    public class Chat implements javax.jms.MessageListener {
    private TopicSession pubSession;
    private TopicSession subSession;
    private TopicPublisher publisher;
    private TopicConnection connection;
    /* Constructor. Establish JMS publisher and subscriber */
    public Chat() throws Exception {
    // Obtain a JNDI connection
    Properties env = new Properties();
    // ... specify the JNDI properties specific to the vendor
    InitialContext jndi = new InitialContext(env);
    // Look up a JMS connection factory
    TopicConnectionFactory conFactory =
    (TopicConnectionFactory) jndi.lookup("TopicConnectionFactory");
    // Create a JMS connection
    TopicConnection connection =
    conFactory.createTopicConnection();
    // Create two JMS session objects
    TopicSession pubSession =
    connection.createTopicSession(false,
    Session.AUTO_ACKNOWLEDGE);
    TopicSession subSession =
    connection.createTopicSession(false,
    Session.AUTO_ACKNOWLEDGE);
    // Look up a JMS topic
    Topic chatTopic = (Topic) jndi.lookup("anytopic");
    // Create a JMS publisher and subscriber
    TopicPublisher publisher =
    pubSession.createPublisher(chatTopic);
    TopicSubscriber subscriber =
    subSession.createSubscriber(chatTopic);
    // Set a JMS message listener
    subscriber.setMessageListener(this);
    // Intialize the Chat application
    set(connection, pubSession, subSession, publisher);
    // Start the JMS connection; allows messages to be delivered
    connection.start();
    /* Initialize the instance variables */
    public void set(TopicConnection con, TopicSession pubSess,
    TopicSession subSess, TopicPublisher pub) {
    this.connection = con;
    this.pubSession = pubSess;
    this.subSession = subSess;
    this.publisher = pub;
    /* Receive message from topic subscriber */
    public void onMessage(Message message) {
    try {
    TextMessage textMessage = (TextMessage) message;
    String text = textMessage.getText();
    System.out.println(text);
    } catch (JMSException jmse) {
    jmse.printStackTrace();
    /* Create and send message using topic publisher */
    protected void writeMessage(String text) throws JMSException {
    TextMessage message = pubSession.createTextMessage();
    publisher.publish(message);
    /* Close the JMS connection */
    public void close() throws JMSException {
    connection.close();
    /* Run the Chat client */
    public static void main(String[] args) {
    try {
    Chat chat = new Chat();
    // Read from command line
    BufferedReader commandLine = new
    java.io.BufferedReader(new
    InputStreamReader(System.in));
    // Loop until the word "exit" is typed
    while (true) {
    String s = commandLine.readLine();
    if (s.equalsIgnoreCase("exit")) {
    chat.close(); // close down connection
    System.exit(0); // exit program
    } else {
    chat.writeMessage(s);
    } catch (Exception e) {
    e.printStackTrace();
    But at the line
    �TopicConnectionFactory conFactory =
    (TopicConnectionFactory) jndi.lookup("TopicConnectionFactory");�
    I got this exception:
    javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial
         at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:640)
         at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:243)
         at javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.java:280)
         at javax.naming.InitialContext.lookup(InitialContext.java:347)
         at chat.Chat.<init>(Chat.java:24)
         at chat.Chat.main(Chat.java:94)
    I realize that the problem is in the jndi setup. But, the problem is that I do not know where to go now and what should I do. I do not know how can I get the jndi.properties file and where and how to put it.
    Please, kindly advise from your experience. I would appreciate clear steps to have this program running properly. Otherwise, if you do have a sample program that is already running, please provide it to me.

    Thank you for your prompt reply.
    I tried another example.
    package test;
    javax.jms.*;
    import javax.naming.*;
    public class SimpleTopicPublisher { /** * Main method. * * @param args the topic used by the example and, * optionally, the number of messages to send */
    public static void main(String[] args) {
    String topicName = null;
    Context jndiContext = null;
    TopicConnectionFactory topicConnectionFactory = null;
    TopicConnection topicConnection = null;
    TopicSession topicSession = null;
    Topic topic = null;
    TopicPublisher topicPublisher = null;
    TextMessage message = null;
    final int NUM_MSGS;
    // if ((args.length < 1) || (args.length > 2)) {
    // System.out.println("Usage: java " + "SimpleTopicPublisher " + "[]");
    // System.exit(1);
    topicName = new String("MyTopic");
    System.out.println("Topic name is " + topicName);
    if (args.length == 2) {
    NUM_MSGS = (new Integer(args[1])).intValue();
    } else {
    NUM_MSGS = 1;
    /* * Create a JNDI API InitialContext object if none exists * yet. */
    try {
    jndiContext = new InitialContext
    } catch (NamingException e) {
    System.out.println("Could not create JNDI API " + "context: " +
    e.toString());
    e.printStackTrace();
    System.exit(1);
    /* * Look up connection factory and topic. If either does * not exist, exit. */
    try {
    topicConnectionFactory = (TopicConnectionFactory) jndiContext.
    lookup("TopicConnectionFactory");
    topic = (Topic) jndiContext.lookup(topicName);
    } catch (NamingException e) {
    System.out.println("JNDI API lookup failed: " + e.toString());
    e.printStackTrace();
    System.exit(1);
    /* * Create connection. * Create session from connection; false means session is * not transacted. * Create publisher and text message. * Send messages, varying text slightly. * Finally, close connection. */
    try {
    topicConnection = topicConnectionFactory.createTopicConnection();
    topicSession = topicConnection.createTopicSession(false,
    Session.AUTO_ACKNOWLEDGE);
    topicPublisher = topicSession.createPublisher(topic);
    message = topicSession.createTextMessage();
    for (int i = 0; i < NUM_MSGS; i++) {
    message
    .setText("This is message " + (i + 1));
    System.out.println("Publishing message: " + message.getText());
    topicPublisher.publish(message);
    } catch (JMSException e) {
    System.out.println("Exception occurred: " + e.toString());
    } finally {
    if (topicConnection != null) {
    try {
    topicConnection.close();
    } catch (JMSException e) {}
    It is mentioned in SUN JMS tutorial that "When you use the J2EE SDK 1.3.1, your JMS provider is the SDK. " So I am using that and I did the follwoing:
    --start the J2EE server as follows:
    j2ee -verbose
    Then I created the adminstrated object:
    j2eeadmin -addJmsDestination MyTopic topic
    But still getting this error:
    javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial
    So now where is the error?
    Thank you in advance

  • What is wrong with my simple program!

    Hello everybody,
    I have a very simple Java program, but it could not run as i expect.
    Could anybody help me firgure it out ?
    Thank you very much in advance
    still_learn
    Here is my program:
    import java.io.*;
    public class Practice
    static InputStreamReader reader = new
    InputStreamReader(System.in);
    static BufferedReader keyboard = new BufferedReader
    (reader);
    public static void main(String[] args) throws
    IOException
    String response;
    do{
         System.out.println("");
         for(int i=0; i<20; i++)
         System.out.println("George Michael");
         do{
         System.out.print("Do you want to continue?
    (y/n) ");
         response = keyboard.readLine();
         }while((response != "y")&&(response != "n"));
              }while(response == "y");
    }// end of main
    }// end of class

    You didn't say what you expected, so debugging becomes very difficult. However I do notice at the end of the code that you compare two strings using == and !=. This does not work. If you want to see if two strings have the same content, use the equals() method of the String class. In your case:}while((!response.equals("y"))&&(!response.equals("n")));
    }while(response.equals("y");

  • Can anybody post me simple programme of finalize() method ?

    i have read as theoretically what is garbage collection and using finalize() method one can achieve but as a student i want to know simple program like we had destructor in c++
    thank you

    The finalize() method is described in the Object's API documentation.
    http://java.sun.com/javase/6/docs/api/java/lang/Object.html
    What is noticable from that description is how few guarantees the method makes. My advice would be don't use it.
    In particular if you try and use finalize() to clean up resources you will face a couple of problems:
    (1) Garbage collection might not ever run.
    (2) Across multiple objects, finalize order is not predictable.
    A better technique for dealing with the "resources" problem - using the finally keyword and an explicit close() method is described here:
    http://java.sun.com/developer/TechTips/2000/tt0124.html

  • Any ideas for a (fairly) simple program?

    Does anybody have any ideas for a fairly simple program that I could try to write (I am a fair programmer, but I'm not to creative)?

    You know, Java Game Programming for Dummies is actually a pretty good book (despite the "Dummies" part!) It is written in 1.0, but it has a "ponglet", card games, and several maze games. All the applets I've tried from them actually work (some typos in the book itself, but the CD is ok). Any of these could be "starter" code.
    Yahoo has a whole bunch of Java applet games. You could try to reproduce pieces of the games you see. (These are also interesting in the sense that you can immediately see what works in a game and what doesn't.)
    It is always fun to write little components. Cool buttons (write a nice little non-rectangular button that lights up or something), text boxes that look like digital displays, funny text labels (maybe with a weird font or with letters that jump all over the place when you mouse over them).. These don't take a whole lot of time to write, but write them well and they are very useful for your future games.
    Enjoy!
    :) jen

  • Invalid method "Save As" from Excel application object

    I have Windows 2000 and Excel 2002 installed on my machine.
    I down loaded "renamed Excel 2000 workbook.vi" from NI website. Relinked ref num to Excel application object but get the error of invalid method (Save As). Tried to relink invoke node to Save As by selecting method from drop down menu. However this method is not on the list. Tried other excel objects but can not find "Save As" method. Has this been removed/moved?

    I was able to correct the error by relinking the Workbooks->Open to Open. This changes the subsequent Invoke Node from IAppEvents to _Workbook. There you will find the Save As method.
    Michael
    www.abcdefirm.com
    Michael Munroe, ABCDEF
    Certified LabVIEW Developer, MCP
    Find and fix bad VI Properties with Property Inspector

  • Table name for 'Program name of method' and 'Method name'

    As we know, each method method contains different  program name with ext. like "====CM0001" etc., Where can I find this program name of method in database tables?
    Note: Program names are in REPOSRC with type as 'I' and name as "CLASS NAME======CMXYZ". But here we can not decide with program name belongs to which class!
    Thanks,
    Naveen.I

    Use FM SEO_CLASS_GET_METHOD_INCLUDES. Provide your class name and you will get the method names with include name.
    Regards,
    Naimesh Patel

  • Please help me with simple program

    Can someone please write a simple program for me that opens up a webpage in the center of the screen , with a set size, and then asks the user where they would like to click on the screen. Then once the person clicks it asks how many times they would like to click there, and then once they enter the # the program opens up the webpage (in the center at the same spot as before, with the same set size) and automatically clicks on the predesignated spot , and then closes all open internet windows, and keeps doing it for however many times the person chose. PLEASE HELP ME WITH THIS!!! If you could, please post the source code here. Thank you so much to whoever helps me!!!!!!!

    If it's not to learn, then what is the purpose of
    this project?well, if it's not HW and its not for learning java, then why the hell would anyone like to have a program that may open a webpage and then repeatedly click on predefined place...
    let me see...
    now if he had asked for program that fakes IP as well, then i would suggest that he tryes to generate unique clicks, but now... i'm not sure... maybe just voting in some polls or smthing... though, i would not create a program that clicks on the link or form element, but rather just reload url with given parameters for N times...

Maybe you are looking for

  • ODI Number of Running Sessions

    Hello guys !! A cuestion, I'm doing a package with a parallel process, but this only raises 3 maximum sessions at the same time, when I hope it raises 9 how can I increase the Number of running sessions / Maximum number of sessions for the agent? Als

  • House numbers

    Hi, I am working on a query that needs to group addresses and should return the first and last house number in that group. However the house numbers are stored as varchar2, but I want a first and last with a best effort to sort them numerically. Hous

  • PC to iMac

    I just got my first Mac yesterday and it is by far the best computer I have ever used, I'm absolutely amazed at how good it runs and how fast it is. I've had no problems at all, I'm so glad I have a Mac now. All I need to know are the basic essential

  • Adobe Updater Not Updating

    I am having INSANE problems with my tablet pen and tried to manually update Photoshop Cloud product and the updater says (both from the Updater Programa and from within Photoshop) that the update has failed. It's driving me nuts.

  • Project import via project catalog

    Hello there, I am still working on my setup environment. Finally, I was able to deploy my setups to git and access them in my installer. There is just something strange. When I don't redirect my installer to my git repository to use my own catalogs a