Member Avatar for 9w43

Hello, I am using Blue J, I have 3 classes, time, date and patient. When I run the patient class, I can put patient details like name, address, DoB, time.

The time and date classes are separate classes, how can I store the date (int) and time which I enter on patient class to be store on date and time classes. I already have fields in time and date classes but I dont know how to link these classes i.e link date class with patient class

I would like to store the date of birth to date class once its entered

Here is my patient class

//Patient Class store patient details such as name, age
    
    /*
     * Field declaration for patient, which stores each input to indicated type
     * p stands for patient (abbreviation)
     * Task 2.1
     */
    public class Patient 
    {
        private int pReference;
        private String pName;
        private String gpName;
        private int pDateD;
        private int pDateM;
        private int pDateY;
        private String pArrived;
        private String pTreated;
        
        
        
        // Constrcutor resets objects
        // Each field is set
        // Task 2.2
        public Patient (int refre, String name, String gp, int day, int month, int year)
        {
            pDateD = day;
            pDateM = month;
            pDateY = year;
            pArrived = null;
            pTreated = null;
            pReference = refre;
            gpName = gp;
            pName = name;
        }
        
        // Accessor returns patient reference
        // Task 2.3
        public int getPatientNo()
        {
            return pReference; 
        }
        
        // Accessor returns GP name given to gpName
        // Task 2.3
        public String getGPName()
        {
            return gpName;
        }
        
        // Accessor returns date of birth in correct format
        // Task 2.3
        public String getDOB()
        {
            char dash = '/';
            return "" + pDateD + dash + pDateM + dash + pDateY;
        }

    }

It sounds like you just want to access some fields form this class? So I guess in the date class, you would just construct a new Patient object and access the date of birth with the getDOB() method:

Patient p = new Patient(......);
String birth = p.getDOB();

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.