Skip to content

Instantly share code, notes, and snippets.

@nbavafa
Created March 11, 2015 21:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nbavafa/56db525508e1d3d16f9b to your computer and use it in GitHub Desktop.
Save nbavafa/56db525508e1d3d16f9b to your computer and use it in GitHub Desktop.
DoctorsOffice
package interitanceLab;
public class Chiropractor implements DoctorsOffice{
private int patientsWithBackProblems;
private double costsPerCustomers;
private int numDoctors;
private int doctorSalary;
public Chiropractor(int patients, double costs, int doctors, int salary) {
patientsWithBackProblems = patients;
costsPerCustomers = costs;
numDoctors = doctors;
doctorSalary = salary;
}
@Override
public double totalAmountBilledToInsurance() {
return BilledToInsurance(); }
@Override
public double costOfServices() {
return CostOfServices(); }
private double BilledToInsurance() {
return patientsWithBackProblems * costsPerCustomers;
}
private int CostOfServices() {
return numDoctors * doctorSalary;
}
}
package interitanceLab;
public class Dentist implements DoctorsOffice{
int numPeopleThatNeedFilling;
double costOfFilling;
public Dentist(int num, double cost) {
numPeopleThatNeedFilling = num;
costOfFilling = cost;
}
@Override
public double totalAmountBilledToInsurance() {
return costOfFilling(); }
@Override
public double costOfServices() {
return costOfFilling(); }
public double costOfFilling() {
return costOfFilling * numPeopleThatNeedFilling;
}
}
package interitanceLab;
import java.text.NumberFormat;
public class Driver {
public static void main (String args []){
NumberFormat money = NumberFormat.getCurrencyInstance();
DoctorsOffice chiro1 = new Chiropractor(123, 79.43, 12, 80300);
DoctorsOffice chiro2 = new Chiropractor(106, 129.90, 8, 120000);
DoctorsOffice chiro3 = new Chiropractor(12, 95.40, 10, 87500);
DoctorsOffice opt1 = new Optician(212, 157.69, 12, 2000.50);
DoctorsOffice opt2 = new Optician(12.64, 79.43, 12, 11200);
DoctorsOffice opt3 = new Optician(246.97, 385.02, 84, 9999.99);
DoctorsOffice dent1 = new Dentist(56, 212.45);
DoctorsOffice dent2 = new Dentist(1089, 197.98);
DoctorsOffice dent3 = new Dentist(600, 200.34);
DoctorsOffice [] office = {chiro1, opt1, dent1, chiro2, opt2, dent2, chiro3, opt3, dent3};
System.out.println("**************************************************************************************");
double total=0;
double totalCost =0;
for (int i = 0; i < office.length; i++) {
int count = 0;
if (office[i].getClass() == Dentist.class) {
count++;
System.out.println("Dentist Dentist Office"+ count + ":\t" + "Amount Billed To Insurance:"
+ "\tCosts of Services:");
System.out.println("\t\t\t\t\t\t" + money.format(office[i].totalAmountBilledToInsurance()) + "\t\t"
+ money.format(office[i].costOfServices()));
total += office[i].totalAmountBilledToInsurance();
totalCost += office[i].costOfServices();
}
}
System.out.println("Totals:\t\t\t\t" + "Billed:" + "\t\t\t\t" + "Costs:");
System.out.println("\t\t\t\t" + money.format(total)+ "\t\t\t" + money.format(totalCost));
System.out.println("**************************************************************************************\n");
System.out.println("**************************************************************************************");
total=0;
totalCost =0;
for (int i = 0; i < office.length; i++) {
int count = 0;
if (office[i].getClass() == Chiropractor.class) {
count++;
System.out.println("Chiropractor Chiro Office"+ count + ":\t" + "Amount Billed To Insurance:"
+ "\tCosts of Services:");
System.out.println("\t\t\t\t\t\t" + money.format(office[i].totalAmountBilledToInsurance()) + "\t\t"
+ money.format(office[i].costOfServices()));
total += office[i].totalAmountBilledToInsurance();
totalCost += office[i].costOfServices();
}
}
System.out.println("Totals:\t\t\t\t" + "Billed:" + "\t\t\t\t" + "Costs:");
System.out.println("\t\t\t\t" + money.format(total)+ "\t\t\t" + money.format(totalCost));
System.out.println("**************************************************************************************\n");
System.out.println("**************************************************************************************");
total=0;
totalCost =0;
for (int i = 0; i < office.length; i++) {
int count = 0;
if (office[i].getClass() == Optician.class) {
count++;
System.out.println("Optician Optic Office"+ count + ":\t" + "Amount Billed To Insurance:"
+ "\tCosts of Services:");
System.out.println("\t\t\t\t\t\t" + money.format(office[i].totalAmountBilledToInsurance()) + "\t\t"
+ money.format(office[i].costOfServices()));
total += office[i].totalAmountBilledToInsurance();
totalCost += office[i].costOfServices();
}
}
System.out.println("Totals:\t\t\t\t" + "Billed:" + "\t\t\t\t" + "Costs:");
System.out.println("\t\t\t\t" + money.format(total)+ "\t\t\t" + money.format(totalCost));
System.out.println("**************************************************************************************");
/**
Store rest1 = new Restaurant(2000, 4, 12, 90, "Southern Comfort");
Store rest2 = new Restaurant(1960, 3, 10, 62, "Califonia Fusion");
Store rest3 = new Restaurant(4500, 6, 16, 200, "Southern Comfort");
Store salon1 = new Salon(1230, 3, 4, 8,"Full Beauty Spa");
Store salon2 = new Salon(650, 2, 2, 2,"Barbershop");
Store salon3 = new Salon(2200, 4, 10, 10,"Full Beauty Spa");
Store ec1 = new ElectronicStore(10200, 10, 28, true, true);
Store ec2 = new ElectronicStore(450, 2, 2, false, true);
Store ec3 = new ElectronicStore(6000, 4, 10, true, false);
Store [] stores = {rest1, salon1, ec1, rest2, salon2, ec2, rest3, salon3, ec3;
*/
}
}
package interitanceLab;
public interface DoctorsOffice {
public double totalAmountBilledToInsurance();
public double costOfServices();
}
package interitanceLab;
public class Optician implements DoctorsOffice{
private double costPerFrame;
private double costOfEyeExam;
private int patients;
private double rent;
public Optician(double frame, double exam, int patients, double rent) {
costPerFrame = frame;
costOfEyeExam = exam;
this.patients = patients;
this.rent = rent;
}
public double BilledToInsurance() {
return (costPerFrame + costOfEyeExam)*patients;
}
public double CostOfServices() {
return rent;
}
@Override
public double totalAmountBilledToInsurance() {
return BilledToInsurance();}
@Override
public double costOfServices() {
return CostOfServices(); }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment