• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 210
  • Last Modified:

Vector

I am having problems listing all the details of my objects.

MedicalConsole.java is the driver program.

You can download the code from:

www.chakracs.com/ourlady/medical.zip

Your help is kindly appreciated.

Regards

Eugene
0
eugene007
Asked:
eugene007
  • 5
  • 5
1 Solution
 
Mayank SAssociate Director - Product EngineeringCommented:
What exactly is the problem? Also - why do you have that infinite while-loop in the main () method?
0
 
eugene007Author Commented:
The problem is when I attemp to list the details of an object, it displays nothing.
0
 
Mayank SAssociate Director - Product EngineeringCommented:
Is it in your listMedicalFacility () method? That method has the following code, as I see:

>> public static void listMedicalFacility()
>> {
>>           Vector mf = hs.getmedicalFacilities();
>>           Iterator iter = mf.iterator();
>>                          
>>           while(iter.hasNext())
>>           {
>>                         
>>           }
>>}

It has a blank while-loop. You're not printing anything there.
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
eugene007Author Commented:
I have problems in this part of the code:

public static void listMedicalFacility()
{
     Vector mf = hs.getmedicalFacilities();
     Iterator iter = mf.iterator();
                          
     while(iter.hasNext())
     {
                         
     }
}
        
      
public static void listPatient()
{
    Vector ps = hs.getPatients();
    Iterator iter = ps.iterator();
                          
    while(iter.hasNext())
    {
             Patient p = (Patient) iter.next();
             System.out.println(p);    
    }
}

               
public static void listProcedure()
{
     Vector pr = hs.getmedicalFacilities();
     Iterator iter = pr.iterator();
                          
     while(iter.hasNext())
     {
             Procedure p = (Procedure) iter.next();
             System.out.println(p);    
     }
}                          
0
 
eugene007Author Commented:
>> public static void listMedicalFacility()
>> {
>>          Vector mf = hs.getmedicalFacilities();
>>          Iterator iter = mf.iterator();
>>                       
>>          while(iter.hasNext())
>>          {
>>                         
>>          }
>>}

I tried this:

>> public static void listMedicalFacility()
>> {
>>          Vector mf = hs.getmedicalFacilities();
>>          Iterator iter = mf.iterator();
>>                       
>>          while(iter.hasNext())
>>          {
>>                     if(iter.next instanceof Hospital)
                          {
                                  Hospital h = (Hospital)iter.next
                                  System.out.println(h);      
                          }  
>>          }
>>}

I am getting error msg.
0
 
Mayank SAssociate Director - Product EngineeringCommented:
What is the error message?
0
 
eugene007Author Commented:
public static void listMedicalFacility()
{
        Vector mf = hs.getmedicalFacilities();
        Iterator iter = mf.iterator();
                          
        while(iter.hasNext())
        {
                    if(iter.next() instanceof Hospital)
                    {
                         Hospital h = (Hospital) iter.next();
                         System.out.println(h);
                     }
       }
}




the error that I receive is exception in thread, for the code above.

0
 
Mayank SAssociate Director - Product EngineeringCommented:
Yes, but what is the exception-message? Anyway, why are you calling next () two times? You should call it only once. Perhaps you are getting a ClassCastException.

public static void listMedicalFacility()
{
        Vector mf = hs.getmedicalFacilities();
        Iterator iter = mf.iterator();
                       
        while(iter.hasNext())
        {
                    Object o = iter.next () ;

                    if ( o instanceof Hospital )
                    {
                         Hospital h = ( Hospital ) o ;
                         System.out.println(h);
                     }
       }
}
0
 
eugene007Author Commented:
ok that works as for the

public static void listProcedure()
{
      Vector mf = hs.getmedicalFacilities();
      Iterator iter1 = mf.iterator();
                                            
      while(iter1.hasNext())
      {
              Object o = iter1.next();
                                     
              if(o instanceof Hospital)
              {
                    Hospital h = (Hospital) o;           
                    Vector pr = h.getProcedures();
 
                    Iterator iter2 = pr.iterator();
          
                    while(iter2.hasNext())
                    {
                         Procedure p = (Procedure) iter2.next();
                         System.out.println(p);    
                    }
              }
       }
}

would it be right to code it this way?.
0
 
Mayank SAssociate Director - Product EngineeringCommented:
Yeah, that's fine.
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

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