Part ASimple Classes Lets start with 2 classes The Procedur
Part A:(Simple Classes) – Let’s start with 2 classes: The Procedure class, and the Appointment class. Let’s build these 2 classes first, we will add the other classes as we go. Your classes should include set and get methods, constructors, a display method and any other behaviors that you deem necessary. (Note: See Database provided to figure out what Properties you need for each class.) Part B:(Inheritance) – Let’s now build 3 more classes: The Person class, the Patient class and the Dentist class. Build the Person class first and test it. Then build the Patient and Dentist classes, and make them inherit from the Person class. All your classes should include set and get methods, constructors, a display method and any other behaviors that you deem necessary. (Note: See Database provided to figure out what Properties you need for each class.) Part C:(Containment) • Next add an Appointment Property to the Patient class. In our Scenario a Patient can only have one appointment scheduled at a time. Make changes to the set & get methods and display method. • Next build and Test an AppointmentList class. Properties: An array of Appointments and a Count. Constructors: only a default constructor is needed. Behaviors: addAppointment(Appointment a) and display(). To test the AppointmentList class, instantiate an AppointmnetList object and add maybe 2 Appointments to the AppointmentList, and then display() the AppointmentList. • Lastly, add an AppointmentList property to the Dentist class. The Dentist’s display() function will also need to be modified to display() the Dentist’s AppointmentList.
id passwd firstName lastName email office
D201 frank Frank Martin fm@gmail.com 539 D202 12345 Susan Cassidy scass@yahoo.com 540 D203 99999 Jerry York jyork@hotmail.com 550 D204 9999 Wayne Pattersen wpatt@gmail.com 552
patId passwd firstName lastName addr email insCo
A900 1234 Jimmy Hawkins Marietta jhawk@yahoo.com Cigna A901 9999 Bill Smith Acworth bsmith@gmail.com Aetna A902 8888 Teri Smart Atlanta tsm@yahoo.com Blue Cross A903 7777 James Roy Acworth jamesray@yahoo.com Blue Cross
procCode procName procDesc cost
P114 Cleaning/Exam Teeth Cleaning and a Dentist Exam 99.99 P119 Xrays Take Xrays of all teeth 320 P122 Whitening Teeth Whitening 129.99 P321 Cavity Fill a cavity 319 P650 Top Dentures Add top dentures 1950
apptDateTime patId dentId procCode
Dec 1, 2013, 9am A900 D201 P321 Dec 2, 2013, 10am A901 D201 P114 Dec 1, 2013, 1pm A902 D202 P114 Dec 1, 2013, 9am A903 D203 P114 Dec 2, 2013, 11am A904 D203 P114 Dec 1, 2013, 3pm A905 D203 P650
Solution
Procedure class:
public class Procedure {
private String procCode;
private String procName;
private String procDesc;
private double cost;
public Procedure(){
}
public Procedure(String procCode, String procName, String procDesc, double cost){
this.procCode = procCode;
this.procName = procName;
this.procDesc = procDesc;
this.cost = cost;
}
public String getProcCode() {
return procCode;
}
public void setProcCode(String procCode) {
this.procCode = procCode;
}
public String getProcName() {
return procName;
}
public void setProcName(String procName) {
this.procName = procName;
}
public String getProcDesc() {
return procDesc;
}
public void setProcDesc(String procDesc) {
this.procDesc = procDesc;
}
public double getCost() {
return cost;
}
public void setCost(double cost) {
this.cost = cost;
}
public void display(){
System.out.print(this.procCode + \"\\t\" + this.procName + \"\ \" + this.procDesc + \"\ \" + this.cost);
}
}
Appointment class:
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
public class Appointment {
private Date appDateTime;
private String paId;
private String denId;
private String procCode;
public Appointment(){
}
public Appointment(Date appDateTime, String paId, String denId, String procCode){
this.appDateTime = appDateTime;
this.paId = paId;
this.denId = denId;
this.procCode = procCode;
}
public Date getAppDateTime() {
return appDateTime;
}
public void setAppDateTime(Date appDateTime) {
this.appDateTime = appDateTime;
}
public String getPaId() {
return paId;
}
public void setPaId(String paId) {
this.paId = paId;
}
public String getDenId() {
return denId;
}
public void setDenId(String denId) {
this.denId = denId;
}
public String getProcCode() {
return procCode;
}
public void setProcCode(String procCode) {
this.procCode = procCode;
}
public void display(){
SimpleDateFormat sdf = new SimpleDateFormat(\"MMM d, yyyy, hhaaa\");
System.out.print(sdf.format(this.appDateTime) + \"\\t\" + this.paId + \"\\t\" + this.denId + \"\\t\" + this.procCode);
}
}
Person class:
public class Person {
private String passwd;
private String firstName;
private String lastName;
private String email;
public Person(){
}
public Person(String passwd, String firstName, String lastName, String email){
this.passwd = passwd;
this.firstName = firstName;
this.lastName = lastName;
this.email = email;
}
public String getPasswd() {
return passwd;
}
public void setPasswd(String passwd) {
this.passwd = passwd;
}
public String getFirstNmae() {
return firstName;
}
public void setFirstNmae(String firstNmae) {
this.firstName = firstNmae;
}
public String getLastNmae() {
return lastName;
}
public void setLastNmae(String lastNmae) {
this.lastName = lastNmae;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public void display(){
System.out.print(this.passwd + \"\\t\" + this.firstName + \"\\t\" + this.lastName + \"\\t\" + this.email);
}
}
Patient class:
public class Patient extends Person {
private String paId;
private String addr;
private String insCo;
private Appointment appointment;
public Patient(){
}
public Patient(String paId, String passwd, String firstName, String lastName, String email, String addr, String insCo){
super(passwd, firstName, lastName, email);
this.paId = paId;
this.addr = addr;
this.insCo = insCo;
}
public String getPaId() {
return paId;
}
public void setPaId(String paId) {
this.paId = paId;
}
public String getAddr() {
return addr;
}
public void setAddr(String addr) {
this.addr = addr;
}
public String getInsCo() {
return insCo;
}
public void setInsCo(String insCo) {
this.insCo = insCo;
}
public void display(){
System.out.print(this.paId + \"\\t\");
display();
System.out.print(\"\\t\" + this.addr + \"\\t\" + this.insCo);
}
public Appointment getAppointment() {
return appointment;
}
public void setAppointment(Appointment appointment) {
this.appointment = appointment;
}
}
Dentist class:
public class Dentist extends Person {
private String id;
private int office;
private AppointmentList appointmentList;
public Dentist(){
}
public Dentist(String id, String passwd, String firstName, String lastName, String email, int office){
super(passwd, firstName, lastName, email);
this.id = id;
this.office = office;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public int getOffice() {
return office;
}
public void setOffice(int office) {
this.office = office;
}
public AppointmentList getAppointmentList() {
return appointmentList;
}
public void setAppointmentList(AppointmentList appointmentList) {
this.appointmentList = appointmentList;
}
public void display(){
System.out.print(this.id + \"\\t\");
super.display();
System.out.println(\"\\t\" + this.office);
System.out.println(\"Appointments List:\");
this.appointmentList.display();
}
}
AppointmentList class:
import java.util.Date;
public class AppointmentList {
private Appointment[] appointmentList = new Appointment[100];
private int count = -1;
public Appointment[] getAppointmentList() {
return appointmentList;
}
public void addAppointment(Appointment appointment) {
this.count += 1;
this.appointmentList[this.count] = appointment;
}
public int getCount() {
return count;
}
public void display(){
for(int i = 0; i <= this.count; i++){
System.out.println();
this.appointmentList[i].display();
}
}
public static void main(String[] args) {
Appointment a1 = new Appointment(new Date(), \"A900\", \"D201\", \"P321\");
Appointment a2 = new Appointment(new Date(), \"A901\", \"D301\", \"P456\");
AppointmentList al = new AppointmentList();
al.addAppointment(a1);
al.addAppointment(a2);
al.display();
}
}





