Hello Im creating a class called Bill I need to design the c

Hello. I\'m creating a class called Bill. I need to design the class Bill with data members to store patient’s ID and the patient’s hospital charges such as pharmacy charges for medicine, and doctor’s fee, and the room charges. And I need to add appropriate constructors and methods to initialize, access, and manipulate the data members. I\'m struggling with this class. Thank you for the help. I\'ll provide my current classes below.

Person.java

-----------


public class Person {
  
   private String lastName;
   private String firstName;
  
   public Person(String last, String first)
   {
       this.lastName = last;
       this.firstName = first;
   }

   public String getLastName() {
       return lastName;
   }

   public void setLastName(String lastName) {
       this.lastName = lastName;
   }

   public String getFirstName() {
       return firstName;
   }

   public void setFirstName(String firstName) {
       this.firstName = firstName;
   }
  
   public String toString()
   {
       return lastName + \", \" + firstName;
   }

}

---------------

Doctor.java

----------------

public class Doctor extends Person { // doctor class that inherits the person class

   String Speciality;

   public Doctor(String last, String first) { // constructor
       super(last, first);
   }

   @Override
   public String toString() { // method that return the data of the doctor
       return \"Doctor{\" + \"Speciality=\" + Speciality + \'}\';
   }

   public String getSpeciality() {
       return Speciality;
   }

   public void setSpeciality(String Speciality) {
       this.Speciality = Speciality;
   }

}

------------

Patient.java

------------

public class Patient extends Person{
  
private int PatientId;
private int age;
private Doctor attendingPhysician;
private Date dob;
private Date admitted,discharged;
  
public Patient(String firstName,String lastName,int PatientId,int age,Doctor attendingPhysician,Date dob,Date admitted,Date discharged)
{
super(lastName,firstName);
this.PatientId = PatientId;
this.age = age;
this.admitted = admitted;
this.discharged = discharged;
this.dob = dob;
this.attendingPhysician = attendingPhysician;
}
  
public int getPatientId()
{
return PatientId;
}
  
public int getAge()
{
return age;
}
  
public Date getAdmissionDate()
{
return admitted;
}
  
public Date getDischargedDate()
{
return discharged;
}
  
public Date getDOB()
{
return dob;
}
  
public Doctor getPhysician()
{
return attendingPhysician;
}
  
public void setPatientId(int PatientId)
{
this.PatientId = PatientId;
}
  
public void setAge(int age)
{
this.age = age;
}
  
public void setAdmissionDate(Date admitted)
{
this.admitted = admitted;
}
  
public void setDischargedDate(Date discharged)
{
this.discharged = discharged;
}
  
public void setDOB(Date dob)
{
this.dob = dob;
}
  
public void setPhysician(Doctor attendingPhysician)
{
this.attendingPhysician = attendingPhysician;
}
  
}

------------

Date.java

--------------


public class Date {
  
   private int year;
   private int month;
   private int day;
  
   public Date()
   {
       year = 1900;
       month = 1;
       day = 1;
   }
  
   public Date(int y, int m, int d)
   {
       year = y;
       month = m;
       day = d;
   }
  
   public String toString()
   {
       return month + \"/\" + day + \"/\" + year;
   }

   public int getYear() {
       return year;
   }

   public void setYear(int year) {
       this.year = year;
   }

   public int getMonth() {
       return month;
   }

   public void setMonth(int month) {
       this.month = month;
   }

   public int getDay() {
       return day;
   }

   public void setDay(int day) {
       this.day = day;
   }
  
  
}



Solution

Bill.java

class Bill extends Patient,Doctor

{

float docorFees;

float pharmacyFees,roomCharge;

float amt;

public:

Bill()

{

doctorFees=pharmacyFees=roomFees=0.0;

}

void setdata(float DC,float PC,float RC)

{

doctorFees=DC;

pharmacyFees=PC;

roomFees=RC;

}

void genBill()

{

roomFees=roomFees*(discharged-admitted);

amt=doctorFees+ pharmacyFees+ roomFees;

}

}

void displayBill(Patient p,Doctor d)

{

cout<<\"Patient I\'d is: \"<<p.getPatientId()<<endl;

cout<<\"Doctor attended is :\"<<p.getPhysician()<<endl;

cout <<Total bill is : \"<<amt<<endl;

}

}

void main()

{

Doctor d(\"Manchu\",\"Prabha\");

Patient p(\"Hari\",\"Vardhan\",1020,29,d,\"13/06/87\",\"21/04/16\",\"29/04/16\");

Bill b;

b.seqtdata(5000,15000,2500);

b.display(p,d);

}

Hello. I\'m creating a class called Bill. I need to design the class Bill with data members to store patient’s ID and the patient’s hospital charges such as pha
Hello. I\'m creating a class called Bill. I need to design the class Bill with data members to store patient’s ID and the patient’s hospital charges such as pha
Hello. I\'m creating a class called Bill. I need to design the class Bill with data members to store patient’s ID and the patient’s hospital charges such as pha
Hello. I\'m creating a class called Bill. I need to design the class Bill with data members to store patient’s ID and the patient’s hospital charges such as pha
Hello. I\'m creating a class called Bill. I need to design the class Bill with data members to store patient’s ID and the patient’s hospital charges such as pha

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site