[text] ijk

Viewer

  1. package com;
  2.  
  3. public class DoctorFinderDemo {
  4.  
  5.         public static void main(String[] args) {
  6.                 Doctor A=new Doctor(2,"Sai","Cardiologist",100);
  7.                 System.out.println(A.getDoctorName());
  8.                 System.out.println(A.displayDoctorDetail());
  9.         }
  10.  
  11. }
  12. package com;
  13.  
  14. public class Doctor {
  15.         int regNo;
  16.         String doctorName;
  17.         String specialization;
  18.         int consultingFee;
  19.         public Doctor(int regNo, String doctorName, String specialization, int consultingFee) {
  20.                 super();
  21.                 this.regNo = regNo;
  22.                 this.doctorName = doctorName;
  23.                 this.specialization = specialization;
  24.                 this.consultingFee = consultingFee;
  25.         }
  26.         public int getRegNo() {
  27.                 return regNo;
  28.         }
  29.         public void setRegNo(int regNo) {
  30.                 this.regNo = regNo;
  31.         }
  32.         public String getDoctorName() {
  33.                 return doctorName;
  34.         }
  35.         public void setDoctorName(String doctorName) {
  36.                 this.doctorName = doctorName;
  37.         }
  38.         public String getSpecialization() {
  39.                 return specialization;
  40.         }
  41.         public void setSpecialization(String specialization) {
  42.                 this.specialization = specialization;
  43.         }
  44.         public int getConsultingFee() {
  45.                 return consultingFee;
  46.         }
  47.         public void setConsultingFee(int consultingFee) {
  48.                 this.consultingFee = consultingFee;
  49.         }
  50.         public String displayDoctorDetail()
  51.         {
  52.        
  53.                 String name= "Doctor Name :"+getDoctorName()+" Specialization :"+ getSpecialization();
  54.                 return name;
  55.         }
  56.  
  57. }

Editor

You can edit this paste and save as new: