Please help me on recursive function call

    *   The function which build the category tree
    public String categoryTree(Statement stat, boolean isMore, int id) {
        if(!isMore) {
            return "";
        else
           String sql = " select t_category_relation.category_relation_id, t_category_relation.level_in, " +
                        " t_category_item.category_item_id, t_category_item.category_name_jpn_NV from " +
                        " t_category_item, t_category_relation " +
                        " where " +
                        " t_category_item.category_item_id = t_category_relation.category_item_id and " +
                        " t_category_relation.parent_id = " + id + " and t_category_relation.parent_id<>0";
//           return sql;
           try{
               ResultSet res = stat.executeQuery(sql);
               String spacer = "";
               String input = "";
               while(res.next()) {
                    int level = res.getInt(2);
                     id = res.getInt(1);
                     for(int i = 0; i < level; i ++) {
                        spacer +="   ";
                     input ="+ id: " +id + " NAME  " + res.getString(4) + "\n</td>\n<td align=center>\n<input type=checkbox value=" +String.valueOf(id) + " name=categoryid>\n</td>\n</tr>\n";
                     return "\t\t<TR>\n\t\t\t<TD>" + spacer + input + categoryTree(stat, true, id);
               if(spacer.equals("")){
                    return input+categoryTree(stat, false, id);
            }catch(SQLException e) {
                    return "SQL Exception";
            return categoryTree(stat, false, id);
    } I am writing a recusive function which can generate a tree like category tree for customer navigation purpose.I don't know why my will loop only return once which means if category "vegetable" has two child and one of child has another child but the result will only display vegetable-->child-->grand child instead of vegetable-> 2 child -> one grand child of one of the child.Please help exam the codethax in

Didn't I already answer this?

Similar Messages

  • Help!! recursive function call

        *   The function which build the category tree
        public String categoryTree(Statement stat, boolean isMore, int id) {
            if(!isMore) {
                return "";
            else
               String sql = " select t_category_relation.category_relation_id, t_category_relation.level_in, " +
                            " t_category_item.category_item_id, t_category_item.category_name_jpn_NV from " +
                            " t_category_item, t_category_relation " +
                            " where " +
                            " t_category_item.category_item_id = t_category_relation.category_item_id and " +
                            " t_category_relation.parent_id = " + id + " and t_category_relation.parent_id<>0";
    //           return sql;
               try{
                   ResultSet res = stat.executeQuery(sql);
                   String spacer = "";
                   String input = "";
                   while(res.next()) {
                        int level = res.getInt(2);
                         id = res.getInt(1);
                         for(int i = 0; i < level; i ++) {
                            spacer +="   ";
                         input ="+ id: " +id + " NAME  " + res.getString(4) + "\n</td>\n<td align=center>\n<input type=checkbox value=" +String.valueOf(id) + " name=categoryid>\n</td>\n</tr>\n";
                         return "\t\t<TR>\n\t\t\t<TD>" + spacer + input + categoryTree(stat, true, id);
                   if(spacer.equals("")){
                        return input+categoryTree(stat, false, id);
                }catch(SQLException e) {
                        return "SQL Exception";
                return categoryTree(stat, false, id);
        }I am writing a menu generated base on a tree like relation ship that is store in a database. assume
    vegetable has two child and one of the child has another child and so forth.
    But I am getting a result like this:
    vegetable-->
    <1>childe
    <1.1>childe
    but missing <2>child
    because the while loop doesn't continous looping after the 1.1.
    please help me out
    thanx in advance

    >
    Re: help!! recursive function call
    Author: DrClap Aug 3, 2001 1:15 PM
    When you call the method recursively, the second call makes a second query to the database, before you have finished using the ResultSet from the first query. Since you are using the same Statement, executing the second query causes the first query to, um, disappear.
    The API documentation for java.sql.Statement says this: "Only one ResultSet object per Statement object can be open at any point in time. Therefore, if the reading of one ResultSet object is interleaved with the reading of another, each must have been generated by different Statement objects. All statement execute methods implicitly close a statment's current ResultSet object if an open one exists."
    thanx for your reply!
        public String categoryTree(int id) {
               String sql = " select t_category_relation.category_relation_id, t_category_relation.level_in, " +
                            " t_category_item.category_item_id, t_category_item.category_name_jpn_NV from " +
                            " t_category_item, t_category_relation " +
                            " where " +
                            " t_category_item.category_item_id = t_category_relation.category_item_id and " +
                            " t_category_relation.parent_id = " + id;
               try{
                   Connection con = DataSourceUtil.getConnection("name");
                   Statement stat = con.createStatement();
                   ResultSet res = stat.executeQuery(sql);
                   String spacer = "";
                   String row = "";
                   while(res.next()) {
                        int level = res.getInt(2);
                         id = res.getInt(1);
                         for(int i = 0; i < level; i++) {
                            spacer +="   ";
                        row = " \t\t<tr>\n " +
                              " \t\t\t<td colspan='2'>" + spacer + " <a href=inventory_edit_product.jsp?categoryid=" + id +">" + res.getString(4) + "</a></td>\n" +
                              " \t\t</tr>\n ";
                         return (row + categoryTree(id));
                   con.close();
                }catch(SQLException e) {
                        return "<tr><td colspan=2>SQL Exception</td></tr>";
                return "";
        }New I think every recursive call will have it's own statement and resultSet but I am still getting same problem. The while loop stopped when calls reached first base case. Does anybody know why. I expect, assume that while loop will go next when a call reaches the base case which will return "".
    Thanx for help

  • Validation of recursive function call fails

    We want to use a call to a recursive function from a HTMLDB application. It should be used in a page region to generate a query string ("PL/SQL function body returning SQL query"). Everything works fine with a call to a non-recursive function. The recursive function also works fine when called from SQL+.
    After pressing "Apply changes" on "HTML DB Home>Builder - Application 148>Page Definition>Edit Page Region"-page I get the following error message after a long delay:
    Function returning SQL query: Query cannot be parsed within the Builder. If you believe your query is syntactically correct, check the ''generic columns'' checkbox below the region source to proceed without parsing
    (ORA-00600: internal error code, arguments: [kohdtf048], [], [], [], [], [], [], [])
    I assume that the validation routine follows the recursion until the memory limit is reached.
    Please give me a hint how to solve this problem.
    DB version: 10.1.0.2.0
    HTMLDB version: 1.5.0.00.33
    running on Win2000 server

    Since the original function is confidential, I have created a simple one showing the same behavior (and the same error). Termination does not depend on session state:
    Called function (to replace spaces with #):
    create or replace function MF_Test
         p_querystring     varchar2     
         return varchar2 is
         v_position integer;
    begin
         v_position:=instr(p_querystring,' ');
         if v_position=0 then     /* termination condition */
              return p_querystring;
         else
              return substr(p_querystring,1,v_position-1)||'#'||MF_Test(substr(p_querystring,v_position+1));
         end if;
    end MF_Test;
    calling function (from the page region, to generate a query string):
    declare
    q varchar2(500);
    begin
    q:='select * from hardware where model=''';
    q:=q||mf_test(:P3_SEARCH);
    q:=q||'''';
    end
    Validation seems not to terminate in case of recursive function calls.
    Thanks for your input.

  • How to collect returns from recursive function calls without a global var?

    Usually global variables shouldnt be used, I was told. Ok. But:
    How can I avoid using a global var when recursively using a function, when the function returns an object and when I want to have the collection of all these objects as the result?
    For example, I think of determine the users of a group including group nesting. I would write a function that adds the direct group members to a collection as a global var and call itself recusively if a member is another group. This recursively called function
    would do as well: Update the global var and if needed call itself.
    I'm afraid this is no good programming style. What algorithm would be better, prettier? Please dont focus on the example, it is a more general question of how to do.
    Thanks
    Walter

    I rarely needed to create/use recursive functions. Here's one example I did:
    function New-SBSeed {
    <#
    .Synopsis
    Function to create files for disk performance testing. Files will have random numbers as content.
    File name will have 'Seed' prefix and .txt extension.
    .Description
    Function will start with the smallest seed file of 10KB, and end with the Seed file specified in the -SeedSize parameter.
    Function will create seed files in order of magnitude starting with 10KB and ending with 'SeedSize'.
    Files will be created in the current folder.
    .Parameter SeedSize
    Size of the largest seed file generated. Accepted values are:
    10KB
    100KB
    1MB
    10MB
    100MB
    1GB
    10GB
    100GB
    1TB
    .Example
    New-SBSeed -SeedSize 10MB -Verbose
    This example creates seed files starting from the smallest seed 10KB to the seed size specified in the -SeedSize parameter 10MB.
    To see the output you can type in:
    Get-ChildItem -Path .\ -Filter *Seed*
    Sample output:
    Mode LastWriteTime Length Name
    -a--- 8/6/2014 8:26 AM 102544 Seed100KB.txt
    -a--- 8/6/2014 8:26 AM 10254 Seed10KB.txt
    -a--- 8/6/2014 8:39 AM 10254444 Seed10MB.txt
    -a--- 8/6/2014 8:26 AM 1025444 Seed1MB.txt
    .Link
    https://superwidgets.wordpress.com/category/powershell/
    .Notes
    Function by Sam Boutros
    v1.0 - 08/01/2014
    #>
    [CmdletBinding(SupportsShouldProcess=$true,ConfirmImpact='Low')]
    Param(
    [Parameter(Mandatory=$true,
    ValueFromPipeLine=$true,
    ValueFromPipeLineByPropertyName=$true,
    Position=0)]
    [Alias('Seed')]
    [ValidateSet(10KB,100KB,1MB,10MB,100MB,1GB,10GB,100GB,1TB)]
    [Int64]$SeedSize
    $Acceptable = @(10KB,100KB,1MB,10MB,100MB,1GB,10GB,100GB,1TB)
    $Strings = @("10KB","100KB","1MB","10MB","100MB","1GB","10GB","100GB","1TB")
    for ($i=0; $i -lt $Acceptable.Count; $i++) {
    if ($SeedSize -eq $Acceptable[$i]) { $Seed = $i }
    $SeedName = "Seed" + $Strings[$Seed] + ".txt"
    if ($Acceptable[$Seed] -eq 10KB) { # Smallest seed starts from scratch
    $Duration = Measure-Command {
    do {Get-Random -Minimum 100000000 -Maximum 999999999 |
    out-file -Filepath $SeedName -append} while ((Get-Item $SeedName).length -lt $Acceptable[$Seed])
    } else { # Each subsequent seed depends on the prior one
    $PriorSeed = "Seed" + $Strings[$Seed-1] + ".txt"
    if ( -not (Test-Path $PriorSeed)) { New-SBSeed $Acceptable[$Seed-1] } # Recursive function :)
    $Duration = Measure-Command {
    $command = @'
    cmd.exe /C copy $PriorSeed+$PriorSeed+$PriorSeed+$PriorSeed+$PriorSeed+$PriorSeed+$PriorSeed+$PriorSeed+$PriorSeed+$PriorSeed $SeedName /y
    Invoke-Expression -Command:$command
    Get-Random -Minimum 100000000 -Maximum 999999999 | out-file -Filepath $SeedName -append
    Write-Verbose ("Created " + $Strings[$Seed] + " seed $SeedName file in " + $Duration.TotalSeconds + " seconds")
    This is part of the SBTools module and is used by the
    Test-SBDisk function. 
    Example use:
    New-SBSeed 10GB -Verbose
    Test-SBDisk is a multi-threaded function that puts IO load on target disk subsystem and can be used to simulate workloads from multiple machines hitting the same SAN at the same time, and measure disk IO and performance.
    Sam Boutros, Senior Consultant, Software Logic, KOP, PA http://superwidgets.wordpress.com (Please take a moment to Vote as Helpful and/or Mark as Answer, where applicable) _________________________________________________________________________________
    Powershell: Learn it before it's an emergency http://technet.microsoft.com/en-us/scriptcenter/powershell.aspx http://technet.microsoft.com/en-us/scriptcenter/dd793612.aspx

  • Please help me with my incoming calls

    I can call out on my phone and send and receive text messeages but I can't get any call's in. a verizon operater come on. please help me

        We always want to get you connected Jenny! Have you reached out to our Technical Support Team by dialing *611 send from your VZW device? What device are you using? What zip code are you in?
    MatthewS_VZW
    Follow us on Twitter @VZWSUPPORT

  • Please Help - Permutations using recursion..

    Please some body help me in generating permutaions using recursion..exact guidelines are as follows..
    Producing consecutive permutations.Need to develop a method that lists one by one all permutations of the numbers 1, 2, �, n (n is a positive integer).
    (a) Recursive method . Given a verbal description of the algorithm listing all permutations one by one, you are supposed to develop a recursive method with the following header:
    public static boolean nextPermutation(int[] array)The method receives an integer array parameter which is a permutation of integers 1, 2, �, n. If there is �next� permutation to the permutation represented by the array, then the method returns true and the array is changed so that it represents the �next� permutation. If there is no �next� permutation, the method returns false and does not change the array.
    Here is a verbal description of the recursive algorithm you need to implement:
    1. The first permutation is the permutation represented by the sequence (1, 2, �, n).
    2. The last permutation is the permutation represented by the sequence (n, �, 2, 1).
    3. If n a ,...,a 1 is an arbitrary permutation, then the �next� permutation is produced by
    the following procedure:
    (i) If the maximal element of the array (which is n) is not in the first position of the array, say i n = a , where i > 1, then just swap i a and i-1 a . This will give you the �next� permutation in this case.
    (ii) If the maximal element of the array is in the first position, so 1 n = a , then to find
    the �next� permutation to the permutation ( ,..., ) 1 n a a , first find the �next�
    permutation to ( ,..., ) 2 n a a , and then add 1 a to the end of thus obtained array of (n-1) elements.
    (iii) Consecutively applying this algorithm to permutations starting from (1, 2, �, n),you will eventually list all n! possible permutations. The last one will be (n, �, 2, 1).For example, below is the sequence of permutations for n = 3 .
    Please help...i have trying this for long time
    plesae help...i apreciate your time..and help..thank you

    public class Permu {
        public static boolean nextPermutation(int a[]) {
                return(permute(a, 0));
        public static boolean permute(int v[], int start) {
             int n = v.length;
             if (start == (n - 1)) {       //if its the end of the sequence genereated then print them
                count++;
                //print(v,n);
                return false;
            } else {
                for (int i = start; i < n; i++) { //swap the start element with the ith element to get n first sequeces
                    int temp = v[start];
                    v[start] = v;
    v[i] = temp;
    permute(v, start + 1);
    //of the n the first is kept constant the same is applied for the rest sequence
    //int tmp = v[i];
    v[i] = v[start];
    v[start] = temp;
    return true;
         public static void main(String[] args) {
    int v[] = {1, 2};//this is the array which should contain the items      to be permuted
    do{
    for(int i=0;i<2;i++)
    System.out.print(v[i]);
    System.out.println();
    }while(nextPermutation(v));
    [i]Output:
    123
    123
    123
    123
    123
    This is exact code i am trying to run...pls someone help me out...                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • 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

  • Recursive function call 'CABM_READ_BOM'

    Hi,
    I need to do a recursive call to 'CABM_READ_BOM' using different matnr each time.  Data will be stored in i_exp_bom_head and i_exp_bom_item.  Since this is a recursive call to the same routine and iterations depend on the level of BOM how can I keep track of the internal tables returned by its level? 
    FORM READ_BOM using p_matnr.
    CALL FUNCTION 'CABM_READ_BOM'
        EXPORTING
          i_matnr         = p_matnr
          i_werks         = i_bom_select-werks
          i_vbeln         = i_bom_select-vbeln
          i_vbpos         = i_bom_select-posnr
          i_stlal         = i_bom_select-stlal
          i_stlan         = i_bom_select-stlan
          i_datuv         = i_bom_select-erdat
        TABLES
          exp_bom_data    = i_exp_bom_head
          exp_itm_data    = i_exp_bom_item
        EXCEPTIONS
          no_record_found = 1
          OTHERS          = 2.
      LOOP AT i_exp_bom_item WHERE postp = 'N'.
        PERFORM READ_BOM using i_exp_bom_item-idnrk.
      ENDLOOP.
    ENDFORM.
    Points will be awarded.
    Thanks!

    Hi Subramanian,
    Thank you for your prompt reply.
    I'm trying to create master BOM and sub BOM depending on how many levels it is.
    IF i_exp_bom_item-POSTP = 'N' then I call the function module again to create sub BOM.  I will call the function module recursively until  i_exp_bom_item-POSTP <> 'N'.  That will be the lowest level.
    Message was edited by:
            Alex Nguyen

  • Takes patience and knowledge, but please help me with this function

    I know I am asking for a lot, but I've been sitting over this for hours and can't crack it.
    I got these two tables
    create table orders create table products
    (order_no number, (item_no number (4)
    item_no number(4), tem_name varchar2(50)
    order qta number, price number,
    order_date date supplier_id char(3));
    delivered date)
    I am trying to create a function that would give me owed amount for delayed delivery per order. Companies have 30 days to deliver the goods, otherwise they pay penalty 1% of order price for each day of delay.
    I cooked up this and it's giving me results only in case there is one row per order in orders table. Like this:
    ORDER_NO ITEM_NO ORDER_QTA ORDER_DATE RECEIVED
    1002 2 90 29.01.10 01.05.10
    but the moment there is more than one row in orders (like below) I execute the function and get the error message - ORA-01422: exact fetch returns more than requested number of rows
    ORDER_NO ITEM_NO ORDER_QTA ORDER_DATE RECEIVED
    1000 26 82 30.03.10 NULL
    1000 14 35 30.03.10 NULL
    I've written this and it contains a GROUP BY clause and sums the rows. I don't know why I am still getting the error message.PLS HELP!!
    THANKS,
    JANA
    create or replace function debts (aorder_no in number)
    return number is
    amount number;
    rec date;
    begin
    select received into rec from orders where order_no=aorder_no;
    if rec is not null then
    select (to_date(received,'DD-MM-YYYY')-to_date(order_date,'DD-MM-YYYY')-30)* sum((o.order_qta*p.price)*0.01)
    into amount
    from orders o, products p
    where p.item_no = o.item_no
    and o.order_no=aorder_no
    group by (to_date(received,'DD-MM-YYYY')-to_date(order_date,'DD-MM-YYYY')-30);
    return (amount);
    end if;
    if rec is null then
    select (to_date(sysdate,'DD-MM-YYYY')-to_date(order_date,'DD-MM-YYYY')-30)* sum((o.order_qta*p.price)*0.01)
    into amount
    from orders o, products p
    where p.item_no = o.item_no
    and o.order_no=aorder_no
    group by (to_date(sysdate,'DD-MM-YYYY')-to_date(order_date,'DD-MM-YYYY')-30);
    return (amount);
    end if;
    end;
    /

    Sorry,
    I' m new to this forum and to PL/SQL as well, so I am probably not posting these questions correctly . I am using 10g Ex edition. Here is some sample data.
    when I created the function, it was complied ok.
    I execute it on order_no 1001 and everything went fine, but if I execute it on order_no 1000, I get an error message. I think it has something to do with the SQL grouping in my statment, but I'm too unexperienced to figure it out on my own.
    insert into orders values (     1000     ,     26     ,     25     ,'     30-Mar-10     ,     4-Apr-10     );
    insert into orders values (     1000     ,     14     ,     31     ,'     30-Mar-10     ,     1-May-10     );
    insert into orders values (     1001     ,     9     ,     39     ,'     28-Feb-10     ,     null     );
    insert into orders values (     1002     ,     2     ,     95     ,'     29-Jan-10     ,     10-Dec-09     );
    insert into orders values (     1003     ,     23     ,     2     ,'     6-Apr-10     ,     null     );
    insert into orders values (     1004     ,     16     ,     70     ,'     8-Jun-04     ,     null     );
    insert into orders values (     1005     ,     4     ,     76     ,'     6-May-10     ,     null     );
    insert into orders values (     1005     ,     19     ,     86     ,'     6-May-10     ,     null     );
    insert into orders values (     1006     ,     29     ,     86     ,'     8-Apr-10     ,     null     );
    insert into orders values (     1006     ,     30     ,     55     ,'     8-Apr-10     ,     10-Mar-10     );
    insert into orders values (     1007     ,     22     ,     54     ,'     6-Apr-10     ,     null     );
    insert into orders values (     1008     ,     9     ,     54     ,'     23-Jan-10     ,     null     );
    insert into orders values (     1009     ,     16     ,     22     ,'     5-Apr-10     ,     null     );
    insert into orders values (     1010     ,     7     ,     53     ,'     2-Mar-10     ,     null     );
    insert into products values (     1     ,'     product_name1'     ,     61000     ,'     EU1'     );
    insert into products values (     2     ,'     product_name2'     ,     46000     ,'     EU1'     );
    insert into products values (     3     ,'     product_name3'     ,     80000     ,'     EU2'     );
    insert into products values (     4     ,'     product_name4'     ,     15000     ,'     EU3'     );
    insert into products values (     5     ,'     product_name5'     ,     10000     ,'     EU2'     );
    insert into products values (     6     ,'     product_name6'     ,     12000     ,'     EU1'     );
    insert into products values (     7     ,'     product_name7'     ,     73000     ,'     EU3'     );
    insert into products values (     8     ,'     product_name8'     ,     59000     ,'     EU2'     );
    insert into products values (     9     ,'     product_name9'     ,     31000     ,'     EU3'     );
    insert into products values (     10     ,'     product_name10'     ,     80000     ,'     EU1'     );
    insert into products values (     11     ,'     product_name11'     ,     66000     ,'     EU2'     );
    insert into products values (     12     ,'     product_name12'     ,     62000     ,'     US1'     );
    insert into products values (     13     ,'     product_name13'     ,     75000     ,'     EU1'     );
    insert into products values (     14     ,'     product_name14'     ,     32000     ,'     EU2'     );
    insert into products values (     15     ,'     product_name15'     ,     44000     ,'     US1'     );
    insert into products values (     16     ,'     product_name16'     ,     68000     ,'     EU1'     );
    insert into products values (     17     ,'     product_name17'     ,     28000     ,'     US1'     );
    insert into products values (     18     ,'     product_name18'     ,     10000     ,'     EU2'     );
    insert into products values (     19     ,'     product_name19'     ,     69000     ,'     US2'     );
    insert into products values (     20     ,'     product_name20'     ,     24000     ,'     US1'     );
    insert into products values (     21     ,'     product_name1'     ,     40000     ,'     US3'     );
    insert into products values (     22     ,'     product_name2'     ,     95000     ,'     US3'     );
    insert into products values (     23     ,'     product_name3'     ,     31000     ,'     US1'     );
    insert into products values (     24     ,'     product_name4'     ,     100000     ,'     US2'     );
    insert into products values (     25     ,'     product_name5'     ,     64000     ,'     US2'     );
    insert into products values (     26     ,'     product_name6'     ,     91000     ,'     US1'     );
    insert into products values (     27     ,'     product_name7'     ,     65000     ,'     US3'     );
    insert into products values (     28     ,'     product_name8'     ,     86000     ,'     US2'     );
    insert into products values (     29     ,'     product_name9'     ,     62000     ,'     US3'     );
    insert into products values (     30     ,'     product_name10'     ,     13000     ,'     US3'     );

  • 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;}     

  • Please help me Solve Bad Pool Caller Error (Windows 8)

    I'm repeatedly getting "Bad Pool Caller Error" on my Windows 8 PC causing it restart again and again. Tried all I knew, nothing worked. However, I'm able to use the PC in Safe Mode (right now I'm on it). Here is the link to dump files (zipped),
    -https://onedrive.live.com/?cid=574E051B8481CE34&id=574E051B8481CE34%21231
    Thank you in advance,
    Anup Mehra

    AM
    For starters you need to update to win 8.1 ASAP and you need to either remove or update your PGP (Related to PGPsdk.sys PGP Software Development Kit NT Driver from PGP Corporation.) which is dated 2005 and can not possibly work in win 8.
    Then please run driver verifier to find the under lying issue
    These crashes were related to memory corruption (probably caused by a driver). 
    Please run these two tests to verify your memory and find which driver is causing the problem.  Please run verifier  first
    If you are over-clocking anything reset to default before running these tests.
    In other words STOP!!!  
    If you do not know what this means you probably are not
    1-Driver verifier (for complete directions see our wiki here)
    2-Memtest. (You can read more about running memtest here)
    Wanikiya and Dyami--Team Zigzag

  • Im new to java can someone please help me with external method calls

    I have only been doing java for a couple of months using bluej, I really dont understand external method calls, this is for an assignment and i have managed the bulk of the code, ineed to make external calls to the other classes to return and input data.
    this is the code i have writen so far.
    class CD
    // The fields.
    public Artist performer;
    private String album;
    private String genre;
    private int numberOfTracks;
    private int yearReleased;
    *Please enter CD details, text entry requires quote marks "Greatest Hits"
    public CD (String album_Name){
    album = album_Name;
    numberOfTracks = 0;
    yearReleased = 0;
    performer = new Artist();
    /**blank constructor*/
    public CD ()
    {album = "";
                genre = "";
                numberOfTracks = 0;
                yearReleased = 0;
                performer = new Artist();}
    * accessor methods
    /** method to return album details to the output window*/
    public void print_albumDetails(){
    System.out.println("Album: " + album);
    System.out.println("Genre: " + genre);
    System.out.println("Number of Tracks: " + numberOfTracks);}
    /** accessor method to return the name of the album*/
    public String show_album(){
    return album;}
    /** accessor method to show artist details from artist class*/
    public void print_details(){
    performer.print_details();}
    * mutator methods
    /** mutator method to change album name please enter name with quotes*/
    public void change_album(String newAlbum){
    album = newAlbum;}
    /**mutator method for adding the album year and checking it correct
    * please enter a year between 1900 and 2005*/
    public void album_year (int year){
    if ((year < 1900) || (year > 2005))
    System.out.println("sorry the year is incorrect please enter a year between 1900 and 2005");
    else yearReleased = year;}
    /** mutator method to alter the number of tracks and check if the ammount is greater
    * than zero*/
    public void change_Number_Of_Tracks(int no_Of_Tracks){
    if (no_Of_Tracks > 0)
    numberOfTracks = no_Of_Tracks;
    else System.out.println("you have not entered a correct number");}
    /** mutator method to change the genre and check it has been entered correctly
    * Please enter 1 for Soul
    * 2 for Blues
    * 3 for Jazz*/
    public void change_Genre(int Change_Genre){
    if ((Change_Genre <= 0) || (Change_Genre > 3)){
    System.out.println("You have not entered the correct available genres");
    System.out.println("which are 1 for Soul,2 for Blues or 3 for Jazz");}
    else if (Change_Genre == 1)
    genre = "Soul";
    else if (Change_Genre == 2)
    genre = "Blues";
    else if (Change_Genre == 3)
    genre = "Jazz";
    to this i need to add an external call to the class Artist to be able to enter firstname and second name, I know that external calls use dot notation
    and the instance of Artist is called performer but i cant get the call to these methods in the Artist class to work
    Artist class
    /** mutator method to change or add artist first name, remember to add quotes*/
    public void cName(String name){
    firstname = name;}
    /** mutator method to change or add artist surname remember to add quotes*/
    public void csurName(String surname){
    lastname = surname;}
    can some please give me some help

    Also, if you can't get them to work, what is the error message you are getting?
    Baron Samedi

  • 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'.

  • Whenever I try to save a file as a PDF, it tells me it can't save because the file is open somewhere else. This is not the case and I have tried it with different files. Please help. You can also call me at:(301)651-9616

    Whenever I try to save a file as a PDF, it tells me that it can't save, because the file is open somewhere else. I don't have anything else open. I have also tried different files and they all say the same thing. Help.

    Given there are so many problems and removed features in Pages 5, why not just continue using Pages '09?
    http://www.freeforum101.com/iworktipsntrick/viewforum.php?f=22&mforum=iworktipsn trick
    http://www.freeforum101.com/iworktipsntrick/viewtopic.php?t=432&mforum=iworktips ntrick
    Peter

  • Please help : how to know the caller ?

    Hi,
    suppose servlet 'C' can be called by servlet 'A' and servlet 'B'.
    How can servlet 'C' know by which servlet it has been called ? Is there something foreseen in HttpServletRequest ?
    Thanks,
    Javamad.

    If it needs to know that -- and in a good design it should not need to know that -- you could store something in the session object to indicate it.

Maybe you are looking for