Prescription.java
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Date;
public class Prescription{
private int prescriptionId;
private String doctorName;
private String doctorphone;
private String startDate;
private String endDate;
private int number;
private Customer customerOwner;
private HashMap<String, Medicine> includedMedicine;
//----------------
// Constructor(s).
//----------------
public Prescription(int pId, String dName, String dPhone,String sDate,
String eDate,int number,Customer customer) {
setPrescriptionId(pId);
setDoctorName(dName);
setDoctorphone(dPhone);
setStartDate(sDate);
setEndDate(eDate);
setNumber(number);
setCustomerOwner(customer);
includedMedicine= new HashMap<String, Medicine>();
// Note that we're instantiating empty support Collection(s).
}
//------------------
// Accessor methods.
//------------------
public void setPrescriptionId(int id) {
prescriptionId = id;
}
public int getPrescriptionId() {
return prescriptionId;
}
public void setDoctorName(String name) {
doctorName = name;
}
public String getDoctorName() {
return doctorName;
}
public void setDoctorphone(String phone) {
doctorphone = phone;
}
public String getDoctorphone() {
return doctorphone;
}
public void setStartDate(String start) {
startDate = start;
}
public String getStartDate() {
return startDate;
}
public void setEndDate(String end) {
endDate = end;
}
public String getEndDate() {
return endDate;
}
public void setNumber(int u) {
number = u;
}
public int getNumber() {
return number;
}
public void setCustomerOwner(Customer c) {
customerOwner = c;
}
public Customer getCustomerOwner() {
return customerOwner;
}
public HashMap<String, Medicine> getIncludedMedicine() {
return includedMedicine;
}
public String toString() {
return getPrescriptionId() + " - " +
getDoctorName() + " - " +
getDoctorphone() + " - " +
getStartDate() + " - " +
getEndDate() + " - " +
getNumber();
}
public void display() {
System.out.println("=========================");
System.out.println(" Prescription : ");
System.out.println("=========================");
System.out.println("\tPrescription Id: " + getPrescriptionId());
System.out.println("\tCustomerOwner" + getCustomerOwner());
System.out.println("\tNumber: " + getNumber());
System.out.println("\tDoctor Name: " +
getDoctorName());
System.out.println("\tDoctor Phone: " + getDoctorphone());
System.out.println("\tStart Date: " + getStartDate());
System.out.println("\tEnd Date: " + getEndDate());
for (Medicine m : includedMedicine.values()) {
m.display();
System.out.println();
}
}
public void addMedicine(Medicine m){
String key=m.getMedicineName();
includedMedicine.put(key,m);
}
public boolean isOutOfDate(){
Calendar rightnow = Calendar.getInstance();
if(rightnow>endDate) return ture;
else return falae;
}
}