Total members 11895 |It is currently Sun Dec 22, 2024 12:13 pm Login / Join Codemiles

Java

C/C++

PHP

C#

HTML

CSS

ASP

Javascript

JQuery

AJAX

XSD

Python

Matlab

R Scripts

Weka





i have to create doctor class with name,specialization,fees (all data private)..create another class hospital with name,address, doctor array...where we hav two methods ... to caculate if a doctor with given specialisation exists? also to caculate total charges . charge s caculated with no of visists and fees...

please help in fixing the code which follows..
Code:
package doc;

public class Doctor
{ private String name;

private int fees;
private String sp;
private double noVisit;



public String getName() {
   return name;
}
public void setName(String name) {
   this.name = name;
}
public int getFees() {
   return fees;
}
public void setFees(int fees) {
   this.fees = fees;
}
public String getSp() {
   return sp;
}
public void setSp(String sp) {
   this.sp = sp;
}
public double getNoVisit() {
   return noVisit;
}
public void setNoVisit(double noVisit) {
   this.noVisit = noVisit;
}

}



package doc;

public class Hospital
{
   
   
   Doctor[] doc=new Doctor[3];
   
   private String hosName;
   private String  add;
   private int rooms;
   public String getHosName() {
      return hosName;
   }
   public void setHosName(String hosName) {
      this.hosName = hosName;
   }
   public String getAdd() {
      return add;
   }
   public void setAdd(String add) {
      this.add = add;
   }
   public int getRooms() {
      return rooms;
   }
   public void setRooms(int rooms) {
      this.rooms = rooms;
   }
   
   
   Hospital(String hosName,String add,int rooms)
   { this.hosName=hosName;
      this.add=add;
      this.rooms=rooms;
   }
   
   void checDoc(String drName)
   {
      int i;
      int count=0;
      String name;
      for(i=0;i<3;i++)
      {
         if(doc[i].name[i].equals(drName))
         { System.out.println("doctor found");
         }
         else
         {
            System.out.println("doctor not found");
         }
         
      }
   }
   
   
   void totCharges()
   {
   int c;
   double sum=0;
   for(c=0;c<3;c++)
   {   double noVisit;
      double charge[c]=(double) (doc[c].noVisit[c])*1000;
      sum=sum+charge;
      System.out.println("total charges"+sum);
   
   }
   }
   }


public class Main
{
public static void main(String b[])
{
   
   String[] name={"saru","viji","babu"};
   String[]sp={"mbbs","phd","phd"};
   int[] noVisit={5,2,3};
   int i;
   for(i=0;i<3;i++)
   {
   Doctor doc[i]=new Doctor();
   doc[i].setName( name[i]);
   doc[i].setSp( sp[i]);
   doc[i].setNoVisit( noVisit[i]);
   doc[i].checkDoc("saru");
   doc[i].totalCharge();
   }
   
}
}



expecting reply soon....




Author:
Newbie
User avatar Posts: 1
Have thanks: 0 time

I think u should add function to check a doctor with a specific specialization exists or not something close to this :
Code:

 void checDoc
(String spec)
   {
      
int i;
      
int count=0;
      
String name;
      for(
i=0;i<3;i++)
      {
         if(
doc[i].getSp().equals(spec))
         { 
System.out.println("doctor with specialization : "+spec+" is found");
         }
         else
         {
            
System.out.println("doctor not found");
         }
         
      }
   }
 


_________________
M. S. Rakha, Ph.D.
Queen's University
Canada


Author:
Mastermind
User avatar Posts: 2715
Have thanks: 74 time

For this message the author DrRakha has received gratitude : saranyak7
Post new topic Reply to topic  [ 2 posts ] 

  Related Posts  to : about classes
 Abstract Classes in jsp     -  
 how do i create the classes XX and YY?     -  
 How to create and use classes in C++     -  
 Wrapper classes use in java     -  
 instantiating java classes     -  
 java wrapper classes     -  
 inherited in the derived classes     -  
 Add and Remove CSS classes to html tag dynamically     -  
 Nested classes(inner class) in java     -  
 Boxing and unboxing make using wrapper classes     -  



cron





Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
All copyrights reserved to codemiles.com 2007-2011
mileX v1.0 designed by codemiles team
Codemiles.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com