Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 280
  • Last Modified:

Errors now in program need help!

I now get these errors the trying to run the code you hlep with.

JAVA
 SDK...

C:\Documents and Settings\Glyn Jackson\Desktop\Doctors Surgery 2004>set PATH=c:\
j2sdk1.4.1\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem

C:\Documents and Settings\Glyn Jackson\Desktop\Doctors Surgery 2004>javac AppInt
erface.java
.\assignDoctor.java:4: package net.proteanit.util does not exist
import net.proteanit.util.PersistentStringList;
                          ^
.\assignDoctor.java:5: package net.proteanit.util does not exist
import net.proteanit.util.StringList;
                          ^
.\AppButtonInterface.java:148: main(java.lang.String[]) in assignDoctor cannot b
e applied to ()
   e.main();
    ^
.\assignDoctor.java:28: cannot resolve symbol
symbol  : variable patientFile
location: class assignDoctor
    patientFile = new PersistentStringList(strFile);
    ^
.\assignDoctor.java:28: cannot resolve symbol
symbol  : class PersistentStringList
location: class assignDoctor
    patientFile = new PersistentStringList(strFile);
                      ^
5 errors




//down below is the code for assignDoctor class. -------------------------------------------

import javax.swing.*;
import java.io.*;
import net.proteanit.util.PersistentStringList;
import net.proteanit.util.StringList;


public class assignDoctor {
 // private PersistentStringList patientFile;


  public static void main(String[] args) {
    System.out.println("testtststststts");
    assignDoctor ad = new assignDoctor();
    ad.findPatientRecord();
  }


  public boolean findPatientRecord() {
    String strFile = String.valueOf(JOptionPane.showInputDialog(null,
        "Please Enter ID to Search For?", "System Search Question",
        JOptionPane.ERROR_MESSAGE, null, null, "1"));
    System.out.println(strFile);
    File f = new File(strFile);
    if (f.exists()) {
      JOptionPane.showMessageDialog(null, "File Was Found", "System Message: Record Found!", JOptionPane.INFORMATION_MESSAGE);
      // Open the record
    patientFile = new PersistentStringList(strFile);
      return true;
    }
    else {
      JOptionPane.showMessageDialog(null, "There is no Record with that ID!", "System Message", JOptionPane.ERROR_MESSAGE);
      return false;
    }
  }
}










//here is the code for the other call which is generating 1 of the errors also


import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

public class AppButtonInterface extends JFrame {
   private JButton PatientButton, PrintButton, PrintDoctorButon, AssignDoctor, DoctorButton, ExitButton, RemoveButton, RemoveDoctor;

   // set up GUI
   public AppButtonInterface()
   {
      super( "Welcome to Doctors Surgery 2004 v1" );

      // get content pane and set its layout
      Container container = getContentPane();
      container.setLayout( new FlowLayout() );

      // create buttons------------------------------
      PatientButton = new JButton( "Add Patient" );
      container.add( PatientButton );

      PrintButton = new JButton( "Print Patient File" );
      container.add( PrintButton );

      RemoveButton = new JButton( "Remove Patient File" );
      container.add( RemoveButton );

      DoctorButton = new JButton( "Add Doctor" );
      container.add( DoctorButton );

      PrintDoctorButon = new JButton( "Print Doctor File" );
      container.add( PrintDoctorButon );

      RemoveDoctor = new JButton( "Remove Doctor File" );
      container.add( RemoveDoctor );

      AssignDoctor = new JButton( "Assign Patient With Doctor" );
      container.add( AssignDoctor );

      ExitButton = new JButton( "Exit System" );
      container.add( ExitButton );


      // create buttons------------------------------


      // create an instance of inner class ButtonHandler
      // to use for button event handling
      ButtonHandler handler = new ButtonHandler();
      ExitButton.addActionListener( handler );
      PatientButton.addActionListener( handler );
      PrintButton.addActionListener( handler );
      DoctorButton.addActionListener( handler );
      RemoveButton.addActionListener( handler );
      RemoveDoctor.addActionListener( handler );
      PrintDoctorButon.addActionListener( handler );
      AssignDoctor.addActionListener( handler );

      setSize( 400, 200 );
      setVisible( true );

   } // end ButtonTest constructor

   public static void main( String args[] )
   {
      AppButtonInterface application = new AppButtonInterface();
      application.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );

   }

   // inner class for button event handling
   private class ButtonHandler implements ActionListener {

     //HANDLE BUTTON EVENTS
      public void actionPerformed( ActionEvent event )
      {


        // CREATE OBJECT READY TO CALL FROM CLASS
        SystemMessages a = new SystemMessages();
        getPatient b = new getPatient();
        getDoctor c = new getDoctor();



        //EXIT BUTTON EVENT!
        if (event.getActionCommand() == "Exit System")
        {
          //LOAD FROM SYSTEM MESSAGE
          a.exitsystem();
          //EXIT PROGRAM
          System.exit(0);
        }

        else if (event.getActionCommand() == "Add Patient")
        {
            a.loading();
            b.getnewPatient();

        }

        else if (event.getActionCommand() == "Print Patient File")
       {
         a.loading();
         b.PrintPatient();


       }

       else if (event.getActionCommand() == "Remove Patient File")
       {
         a.loading();
         b.RemovePatient();


       }

       else if (event.getActionCommand() == "Add Doctor")
     {
       a.loading();
       c.doctor();


     }

     else if (event.getActionCommand() == "Remove Doctor File")
    {
      a.loading();
      c.RemoveDoctor();


    }

    else if (event.getActionCommand() == "Print Doctor File")
    {
      a.loading();
      c.PrintDoctor();


     }


     else if (event.getActionCommand() == "Assign Patient With Doctor")
     {
   a.loading();
   assignDoctor e = new assignDoctor();
   e.main();

//this is where 1 of the errors is!!!!!!!


     }


      }

   } // end private inner class ButtonHandler

} // end class ButtonTest
0
pigmentarts
Asked:
pigmentarts
  • 5
  • 2
1 Solution
 
CEHJCommented:
>>import net.proteanit.util.PersistentStringList;

If you look at the code i originally gave you, i said to remove these package declarations
0
 
pigmentartsAuthor Commented:
when i did that the line:

 patientFile = new PersistentStringList(strFile);

has an error?
0
 
objectsCommented:
import javax.swing.*;
import java.io.*;

public class assignDoctor {


  public static void main(String[] args) {
    System.out.println("testtststststts");
    assignDoctor ad = new assignDoctor();
    ad.findPatientRecord();
  }


  public boolean findPatientRecord() {
    String strFile = String.valueOf(JOptionPane.showInputDialog(null,
        "Please Enter ID to Search For?", "System Search Question",
        JOptionPane.ERROR_MESSAGE, null, null, "1"));
    System.out.println(strFile);
    File f = new File(strFile);
    if (f.exists()) {
      JOptionPane.showMessageDialog(null, "File Was Found", "System Message: Record Found!", JOptionPane.INFORMATION_MESSAGE);
      return true;
    }
    else {
      JOptionPane.showMessageDialog(null, "There is no Record with that ID!", "System Message", JOptionPane.ERROR_MESSAGE);
      return false;
    }
  }
}
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
objectsCommented:
  else if (event.getActionCommand() == "Assign Patient With Doctor")
     {
   a.loading();
   assignDoctor e = new assignDoctor();
   e.main(null);
}

0
 
objectsCommented:
thats last bit would be better written as the foillowing though:

   else if (event.getActionCommand().equals("Assign Patient With Doctor")
   {
   a.loading();
   assignDoctor e = new assignDoctor();
   e.findPatientRecord();
   }
0
 
objectsCommented:
> else if (event.getActionCommand() == "Assign Patient With Doctor")

and all those tests should use equals method instead of ==

else if (event.getActionCommand().equals("Assign Patient With Doctor"))
0
 
pigmentartsAuthor Commented:
i did not know that why is .equals different then == , and thanks for your help!
0
 
objectsCommented:
== tests for object equality, where the String's equals method tests for string equality.
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 5
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now