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
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
public class Bill {
private double doctorFee,medicineCharge,roomCharge;
private int patientId;
public Bill()
{
}
public Bill(double doctorFee,double medicineCharge,double roomCharge,int patientId)
{
this.doctorFee = doctorFee;
this.medicineCharge = medicineCharge;
this.roomCharge = roomCharge;
this.patientId = patientId;
}
public double getDoctorFee()
{
return doctorFee;
}
public double getMedicineCharge()
{
return medicineCharge;
}
public double getRoomCharge()
{
return roomCharge;
}
public int getPatientId()
{
return patientId;
}
public void setDoctorFee(double doctorFee)
{
this.doctorFee = doctorFee;
}
public void setMedicineCharge(double medicineCharge)
{
this.medicineCharge = medicineCharge;
}
public void setRoomCharge(double roomCharge)
{
this.roomCharge = roomCharge;
}
public void setPatientId(int patientId)
{
this.patientId = patientId;
}
}




