Question
How Can I solve this error? package HW2; public class Patel { class Person { private String name; public String getName() { return name; }
How Can I solve this error?
package HW2;
public class Patel { class Person { private String name; public String getName() { return name; } public void setName(String name) { this.name = name; } @Override public String toString() { return "Person [name=" + name + "]"; }
public Person(String name) { super(); this.name = name; }
public Person() { super(); } public Person(Person p) { this.name = p.getName(); } } class Patient extends Person { private Doctor primary_physician; public Doctor getPrimary_physician() { return primary_physician; } public void setPrimary_physician(Doctor primary_physician) { this.primary_physician = primary_physician; } @Override public String toString() { return "Patient [primary_physician=" + primary_physician + ", getName()=" + getName() + ", toString()="+ super.toString() + ", getClass()=" + getClass() + ", hashCode()=" + hashCode() + "]"; } public Patient(String name, Doctor primary_physician) { super(name); this.primary_physician = primary_physician; } } class Doctor extends Person{ private String specialization; public String getSpecialization() { return specialization; } public void setSpecialization(String specialization) { this.specialization = specialization; } public Doctor(String name, String specialization) { super(name); this.specialization = specialization; } @Override public String toString() { return "Doctor [specialization=" + specialization + ", getName()=" + getName() + ", toString()="+ super.toString() + ", getClass()=" + getClass() + ", hashCode()=" + hashCode() + "]"; } } static class Billing { static double total_income=0; private Patient patient; private Doctor doctor; private double amount_due; public Patient getPatient() { return patient; } public void setPatient(Patient patient) { this.patient = patient; } public Doctor getDoctor() { return doctor; } public void setDoctor(Doctor doctor) { this.doctor = doctor; } public double getAmount_due() { return amount_due; } public void setAmount_due(double amount_due) { this.amount_due = amount_due; } public Billing(Patient patient, Doctor doctor, double amount_due) { super(); this.patient = patient; this.doctor = doctor; this.amount_due = amount_due; setTotal_income(amount_due); } public static double getTotal_income() { return total_income; } public static void setTotal_income(double total_income) { Billing.total_income += total_income; } @Override public String toString() { return "Billing [patient=" + patient + ", doctor=" + doctor + ", amount_due=" + amount_due + "]"; } } public static class Testing { public static void main(String args[]) { Doctor d1 = new Doctor("d1","sp1"); System.out.println(d1.getName()+" "+d1.getSpecialization()); Doctor d2 = new Doctor("d2","sp2"); Patient p1 = new Patient("p1",d1); Patient p2 = new Patient("p2",d2); Patient p3 = new Patient("p3",d1); System.out.println(p1.getName()+" "+p1.getPrimary_physician()); Billing b1 = new Billing(p1,d1,5560); Billing b2 = new Billing(p1,d2,1000); Billing b3 = new Billing(p3,d2,1000); System.out.println(b1.getPatient()); System.out.println(b1.getDoctor()); System.out.println(b1.getAmount_due()); System.out.println(Billing.getTotal_income()); } } }
Doctor di = new Doctor ("alapis: No enclosing instance of type Patel is accessible. Must qualify the allocation with an enclosing instance of System.out.println(d.getName()+" type Patel (e.g. x.new AO where x is an instance of Patel). Press for focu Doctor d2 - new Doctor ("d2", "ap2")
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started