PLEASE help with my add function

I am very new to Java. Sigh, All i want to do is allow the user to input the details for the patient and then add the new patient to a priority queue.
However, i get the error message "cannot find symbol" , "variable testPq" at the following line... "testPq.add(x, x.priority, x.id);"
The relevant bit of the code is as follows, if anyone can help it would be much appreciated.......
import java.io.*;
import java.util.*;
class Clinic {
     int ctime;
     public static void main(String[] args) throws PqException {     
               int age,
                    timearv,
                    choice,
                    id,
                    tl;
               String name;
               Scanner input = new Scanner( System.in );
          Clinic c = new Clinic();
               System.out.println("Create patient's ID");
               id = input.nextInt();
               System.out.println("Add patient's age");
               age = input.nextInt();
               System.out.println("Add patient's trauma level");
               tl = input.nextInt();
               System.out.println("Time of arrival?");
               timearv = input.nextInt();
               System.out.println("Add patient's Name");
               name = input.nextLine();
               Patient x = new Patient(id, name, age, tl, timearv);
               System.out.println(x);
//THIS IS WHERE THE PROBLEM ARISES               
System.out.println("Add patient to queue?");
               choice = input.nextInt();
                    if (choice==1){
                    testPq.add(x, x.priority, x.id);
                    else {
                         System.out.println("Do nada");
     }//end of main
     Clinic(){
          //create priority queue that will hold 10 objects     
     Pq testPq  = new Pq(10);
     }//end of constructor
}//end of clinic
     class Pq {
     static private int maxQueue = 100; // max possible size of queue
  private int size,       // size as created by used
               nq,         // current number of objects in queue
              selector;   // index of selected object
  private PObject q [] = new PObject [maxQueue];
  // Constructor for the Priority queue *****************************
  public Pq(int m) {
    if (m <= maxQueue) size = m;
     else { size = maxQueue;
            System.out.println("Warning: size set to max =100\n");
    nq =0;
  } // of Pq constructor
     //add
     public void add(Object x, int priority, int id) throws PqException {
    if (!(this.isFull())) {
      PObject y = new PObject(x,priority,id);
      q[nq] = y;
       selector = nq; // default setting for the selector
       nq++;
     else throw new PqException("queue is full");
  } // of add
}//end of Pq class
class PObject{
  /* An ancilliary class used to 'wrap up ' objects in the queue and
     so enable a priority and id to be associated with each one. */
  Object obj;
  int priority;
  int id;
  // Constructor method
  PObject(Object x, int p, int s) {
    obj = x;  priority = p; id = s;
  } // of Priority Object constructor
} // of class PObject
class PqException extends Exception {
  PqException (String s) {super(s);}
} // of class PqException ************

2. where does that "isFull" method come from ?His class implements the IOsmosis interface.don't get me started on the whole
"I-prefix-for-interfaces-convention" thing ! Class
names should start with a "C" !i omitted this from the code previously, to save on space....
i have declared the queue in the clinic constructor because a menu driven class when run will create a new clinic, when this new clinic is created it will need to have a Pq in it....everything works fine until i add the line "testPq.add(x, x.priority, x.id);" PLEASE REMEMBER I AM VERY NEW TO ALL OF THIS.....
public boolean isEmpty ()  {return nq == 0;}
     public boolean isFull ()   {return nq == size;}
     public int length()        {return nq;}     

Similar Messages

  • Please help with creating a functional form..

    Hi world,
    I have been able to create a working and functional form using Adobe LiveCycle Designer which others can view and complete as a pdf.  I added a button to where it can be emailed to anyone.
    My question is: The email that automatically is generated currently says
    Form Returned: ProjectInquiryForm test.pdf
    The attached file is the filled-out form. Please open it to review the data.
    And of course there is a pdf attached.  Is there any way to edit this language??
    I am a technology novice so if anyone has step by step or easy instructions it would be greatly greatly appreciated!
    Thanks so much,
    Jennifer

    Thank you for your help.  I was able to create the form, and add the email button functionality, etc.  One last question, The email currently says
    Form Returned: ProjectInquiryForm test.pdf
    The attached file is the filled-out form. Please open it to review the data.
    And then has the pdf attached.  Is there any way to edit this language?
    Thanks again!
    Jennifer

  • Please help with Watch Folders functionality

    I am currently using Elements 11 and cannot get my "Watch Folder" function to stay activated. I have tried averything Adobe has told me to do and it will not stay activated. I can go to START > type in "SERVICES" in the search> activate the "Adobe Active File Monitor V11" to start the service, move photos into my folders, and when I am not notified that there are new items in my catalog, I go back through to the services listing and it has shut off. So all the items I moved into the folders are not registering with Elements catalog and I cannot tag them to bring them up later. Upon exhausting all the ideas that Adobe had for me, my last attempt was to start a new catalog, which involves retagging all my pngs because they do not carry the keyword tags with their metadata. This is not helping either. Has anyone else had an issue with this? And more importantly, a solution? I am wondering if there is a problem with possibly another setting  in my computer that might cause this to malfunction? Or possibly something I need to download (or remove) that could be interfering with this function? If anyone has any input, I would be very grateful.
    Thanks,
    Donna

    Donna,
    If I understand well, you have a kind of folder organization like this:
    /My Pictures
    and  many subfolders under it, among which subfolders you have 'need to organize', 'backgrounds', 'animals', flowers'...
    If you manually have the organizer to 'get photos and videos from files and folders', and point to the My Pictures, it will catch any new files under 'My Pictures', provided you have checked the option to 'include subfolders'.
    Even if this works perfectly and reasonably quickly, you may think it is unnecessary to browse all your pictures to make the process still quicker.
    My suggestion is to have a subfolder hierarchy with a folder named 'photo input' and subfolders according to your needs:
    - photos from camera (tip : use the preference menu to tell the downloader to store your downloaded photos there)
    - photos from scans (same tip as above, you can tell the default save location of your scans)
    - image contents (for your libraries of scrapbooking contents'
    It's easy to 'get ...' either from the 'My Pictures' main folder or only one of those master subfolders
    Another tip : I often get many photos from the mail or the Web, my browser saves them in a temporary folder : I copy them to another main subfolder named 'photos from web'.

  • Please help with slideshow problems!

    Am using Photoshop Elements 8 and trying to make a slideshow. Have tried 4 times now and keep ending up with same problem, cannot reopen project to continue edititing.  Won't show up in orginizer and when I find on harddrive and try to open get message " wmv file cannot be opened".  How can I save a
    slideshow inprogress and be able to reopen and continue to edit and make slideshow?  I want to thank anyone who can help me with this in advance as I
    have gotten so frustrated that I want to just scream.
    Thanks

    Thanks for the help, thought I had done so but maybe not.  Anyway will have another go at it, now may I ask another
    question?  I am trying to add audio to slideshow.  I have some music I purchased thru amazon as mp3 files but I get
    message no codec and when I try to add wmv I get same message.  What type of file do I need and how can I add
    multiple songs to one slideshow.   I have one little wmv file that will go in, but it just replicates itself multiple times until
    it fills slide show. 
    Thanks again, sorry to be a bother, but this thing is driving this old man crazy.
    Date: Sun, 26 Dec 2010 20:34:32 -0700
    From: [email protected]
    To: [email protected]
    Subject: Please help with slideshow problems!
    You need to save the slideshow project in order to be able to go back later and make changes or additions to an existing slideshow . The wmv file is a final output format.
    Now you are most probably using only the Output command: that is what makes the wmv file.
    You should also do the Save Project command. (and I make it a practice to do the Save Project command before I do the Output command).
    If you look at the Elements Organizer 8 Help, there is a topic on "Create a slide show".
    -- Very close to the beginning of that topic is a screen shot of the Sldie Show Editor screen,
    -- The bar below the usual menu bar is labeled with a "B" and called the Shortcuts bar.
    -- The 1st entry on that Shortcuts bar is "Save Project"
    It is the Save Project command that saves the information about which photos, audio, etc you placed in that specific slide show so that you can come back again to do subsequent editing.  Save each Project with a unique name.
    After completing the Save Project command, you shoud see an "icon" in the Organizer for that slide show.
    Note:  you must also keep the photo files and audio files which you have used in this slide show: you can't delete them because the project file does NOT contain a copy of the photos, it only has the identification and folder location of the photo and audio files.
    >

  • HT5824 I switched over from an iPhone to a Samsung Galaxy S3 & I haven't been able to receive any text messages from iPhones. Please help with turning my iMessage completely off..

    I switched over from an iPhone to a Samsung Galaxy S3 & I haven't been able to receive any text messages from iPhones. I have no problem sending the text messages but I'm not receivng any from iPhones at all. It has been about a week now that I'm having this problem. I've already tried fixing it myself and I also went into the sprint store, they tried everything as well. My last option was to contact Apple directly. Please help with turning my iMessage completely off so that I can receive my texts.

    If you registered your iPhone with Apple using a support profile, try going to https://supportprofile.apple.com/MySupportProfile.do and unregistering it.  Also, try changing the password associated with the Apple ID that you were using for iMessage.

  • How can I sync my iPhone on a different computer without erasing my applications? My iPhone was earlier synced with a PC which I don't use anymore. Please help with proper steps, if any.

    How can I sync my iPhone on a different computer without erasing my applications? My iPhone was earlier synced with a PC which I don't use anymore.
    On the new computer, I am getting a message that my all purchases would be deleted if I sync it with new iTunes library.
    Please help with proper steps, if any.

    Also see... these 2 Links...
    Recovering your iTunes library from your iPod or iOS device
    https://discussions.apple.com/docs/DOC-3991
    Syncing to a New Computer...
    https://discussions.apple.com/docs/DOC-3141

  • Please help with "You can't open the application NovamediaDiskSupressor because PowerPC applications are no longer supported." I have seen other responses on this but am not a techie and would not know how to start with that solution.

    Please help with the message I am receving on startup ""You can't open the application NovamediaDiskSupressor because PowerPC applications are no longer supported."
    I have read some of the replies in the Apple Support Communities, but as I am no techie, I would have no idea how I would implement that solution.
    Please help with what I need to type, how, where, etc.
    Many thanks
    AppleSueIn HunterCreek

    I am afraid there is no solution.
    PowerPC refers to the processing chip used by Apple before they transferred to Intel chips. They are very different, and applications written only for PPC Macs cannot work on a Mac running Lion.
    You could contact the developers to see if they have an updated version in the pipeline.

  • Hi, please help with the installation of Lightroom 4, I bought a new Mac (Apple) and I want to install a software that I have on the album cd. My new computer does not have the drives. Can I download software from Adobe? Is my license number just to be ab

    Hi, please help with the installation of Lightroom 4, I bought a new Mac (Apple) and I want to install a software that I have on the album cd. My new computer does not have the drives. Can I download software from Adobe? Is my license number just to be able to download the srtony adobe.

    Adobe - Lightroom : For Macintosh
    Hal

  • [ETL]Could you please help with a problem accessing UML stereotype attributes ?

    Hi all,
    Could you please help with a problem accessing UML stereotype attributes and their values ?
    Here is the description :
    -I created a UML model with Papyrus tool and I applied MARTE profile to this UML model.
    -Then, I applied <<PaStep>> stereotype to an AcceptEventAction ( which is one of the element that I created in this model ), and set the extOpDemand property of the stereotype to 2.7 with Papyrus.
    -Now In the ETL file, I can find the stereotype property of extOpDemand as follows :
    s.attribute.selectOne(a|a.name="extOpDemand") , where s is a variable of type Stereotype.
    -However I can't access the value 2.7 of the extOpDemand attribute of the <<PaStep>> Stereotype. How do I do that ?
    Please help
    Thank you

    Hi Dimitris,
    Thank you , a minimal example is provided now.
    Version of the Epsilon that I am using is : ( Epsilon Core 1.2.0.201408251031 org.eclipse.epsilon.core.feature.feature.group Eclipse.org)
    Instructions for reproducing the problem :
    1-Run the uml2etl.etl transformation with the supplied launch configuration.
    2-Open lqn.model.
    There are two folders inside MinimalExample folder, the one which is called MinimalExample has 4 files, model.uml , lqn.model, uml2lqn.etl and MinimalExampleTransformation.launch.
    The other folder which is LQN has four files. (.project),LQN.emf,LQN.ecore and untitled.model which is an example model conforming to the LQN metamodel to see how the model looks like.
    Thank you
    Mana

  • Want a complete migration guide to upgrade 11.1.0.7 to 11.2.0.3 database using DBUA..We are implementing R12.1.3 version and then have to migrate the default 11gR1 database to 11.2.0.3 version. Please help with some step by step docs

    Want a complete migration guide to upgrade 11.1.0.7 to 11.2.0.3 database using DBUA..We are implementing R12.1.3 version and then have to migrate the default 11gR1 database to 11.2.0.3 version. Please help with some step by step docs

    Upgrade to 11.2.0.3 -- Interoperability Notes Oracle EBS R12 with Oracle Database 11gR2 (11.2.0.3) (Doc ID 1585578.1)
    Upgrade to 11.2.0.4 (latest 11gR2 patchset certified with R12) -- Interoperability Notes EBS 12.0 and 12.1 with Database 11gR2 (Doc ID 1058763.1)
    Thanks,
    Hussein

  • Welcome. At the outset, I'm sorry for my English :) Please help with configuration Photoshop CS6 appearance. How to disable the background of the program so you can see the desktop. (same menus and tools) Chiałbym to be the same effect as CS5.

    Welcome.
    At the outset, I'm sorry for my English
    Please help with configuration Photoshop CS6 appearance.
    How to disable the background of the program so you can see the desktop. (same menus and tools)
    i wantto be the same effect as CS5.

    Please try turning off
    Window > Application Frame

  • HT201210 cont contact apple server error please help with ipad touch 4. im just fed up with apple please help me because why is it only apple with these kind of problems?

    cont contact apple server error please help with ipad touch 4. im just fed up with apple please help me because why is it only apple with these kind of problems?

    If you mean updae server
    Update Server
    Try:
    - Powering off and then back on your router.
    - iTunes for Windows: iTunes cannot contact the iPhone, iPad, or iPod software update server
    - Change the DNS to either Google's or Open DNS servers
    Public DNS — Google Developers
    OpenDNS IP Addresses
    - For one user uninstalling/reinstalling iTunes resolved the problem
    - Try on another computer/network
    - Wait if it is an Apple problem
    Otherwise what server are you talking about

  • HT3209 Purchased DVD in US for Cdn viewing. Digital download will not work in Cda or US? please help with new Digital code that will work

    Purchased DVD in US for Cdn viewing. Digital download will not work in Cda or US? please help with new Digital code that will work

    You will need to contact the movie studio that produced the DVD and ask if they can issue you a new code valid for Canada. Apple cannot help you, and everyone here in these forums is just a fellow user.
    Regards.

  • I have worked many hours on an iphoto book and I am up to page 29.  I cannot add any more pages and I need to!  Please help!!  "Add page" is not working!!!

    I have worked many hours on an iphoto book and I am up to page 29.  I cannot add any more pages past that and I need to!  Please help!!  "Add page" is not working!!!

    Fixed it thanks to similar questions and answers to them.  Thanks all!

  • Hi. I have an iPhone 4s. The music doesn't play when I connect it to my car stereo. It used to play previously but stopped playing all of a sudden. My phone is getting charged when I cut it to the USB port. Please help with this. The iOS is 6.1.3.

    Hi. I have an iPhone 4s. The music doesn't play when I connect it to my car stereo. It used to play previously but stopped playing all of a sudden. My phone is getting charged when I cut it to the USB port. Please help with this. The iOS is 6.1.3.

    Hello Priyanks,
    I found an article with steps you can take to troubleshoot issues with an iPhone not connecting to your car stereo:
    iOS: Troubleshooting car stereo connections
    http://support.apple.com/kb/TS3581
    Thank you for using Apple Support Communities.
    Best,
    Sheila M.

Maybe you are looking for

  • DVD DL with a DVD-rom part

    Hi, With DVD SP 3.0.2, I'm trying to burn a DVD-DL, containing a DVD-video part (2,1 Go) and a DVD-rom part (4 Go). The layer is set to Dual and the Break Point is set to Automatic. DVD SP reports an error : "Formatting Failed. Formatting was not suc

  • Any uses for a old power mac g4

         Is there any use for a old powermac g4 since i have a new 2010 imac.  I love the thing so i tried to get some more use out of it by making it into a server but i can't find disc's for it.  So i tryied making it into a ubuntu server but they stop

  • LibreOffice is crashing

    Hello all, LibreOffice is crashing when trying out the animations, I'm providing the output of the crash: [antun@mashup ~]$ /usr/lib/libreoffice/program/soffice.bin -impress *** glibc detected *** /usr/lib/libreoffice/program/soffice.bin: double free

  • Can I get a notification upon responding to my message?

    I put a message in the board.  Is there a setup so that I get a notification in my e-mail when somebody answers my message? Thanks Rafi

  • Thank you, Adobe for the enhanced actions editor (Was: Thank you, Adobe)

    Just want to thank you for the Enhanced Actions Editor... fantastic! Months ago, I had requested to have something similar that Flash Catalyst had, and you delivered.