Member Avatar for 9w43

I have no idea what to do, it keeps on saying can not find constructor Time(int, int)

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;
        public static Time pArrived;
        public static Time 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;
        }
        public void SetArrivalTime (int hour, int minute)
        { 
            SetArrivalTime(hour, minute);
        }
        
        public Patient()
        {
            super();
        }
        
        // 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;
        }
        
        
        // Mutator setting time
        // Task 2.4
        
        
        public void setArrivalTime (int hour, int minute)
        {
            pArrived = new Time (hour, minute); //error happens here
        }
        
        public void setTreatmentStart(int hour, int minute)
        {
            pTreated = new Time (hour, minute); //error happens here
        }
        
        public String getAsString()
        {
                System.out.println ("Patient Name is " + pName);
                System.out.println ("GP Name is " + gpName);
                System.out.println ("Patient Reference is " + pReference);
                System.out.println ("The Date of Birth is " + pDateD + "/" + pDateM + "/" + pDateY);
                return pName;
        }
    }

and here is my Time Class

/**
 * Handles time(hour:minutes) 
 * If given hour/minutes outside appropriate range, sets to 0
 * @author A.A.Marczyk
 * @version 22/11/06
 */

    // Fields being declared
    public class Time
    {
        private static int hour;
        private static int minute;
        public static int displayTime;
        public static String names = null;
        public static int example2;
    
        // Constrcuter resets objects
        public Time()
        {
            hour = 00;
            minute = 00;
        }
    
        // Mutator for hour field
        private void setHour (int newHour)
        {
            if (hour < 23)
            {
                hour = newHour;
            }
            else 
            { 
                hour = 0;
            }
            if (hour > 23)
            {
                System.out.println ("Please enter the right Hours?");
                hour = 0;
            }
            else
            {
                
            }
        }

        // Mutator to set minute
        private void setMinute (int newMinute)
        {
            if (newMinute <59)
            {
                minute = newMinute;
            }
            else
            {
                minute = 0;
            }
            
            if (newMinute >59)
            {
                System.out.println ("Please enter the right Minutes?");
                minute = 0;
            }
            else
            {

            }
        }
  
        // Method for reseting hours
        public void setTime (int hour,int minute)
        {
            setHour (hour);
            setMinute (minute);
        }
                
        // Constructor for time
        public void increaseTime ()
        {
            
            if (hour < 23)
            {
                hour++;
            }
            else
            {
                hour = 0;
            }
            if (minute < 59)
            {
                minute++;
            }
            else
            {
                minute = 0;
            }
        }
        
        private static void gettingTimeArrived (int hour, int minute)
        {
            Patient.pArrived = new Time ();
        }
        
         private static void gettingTreated (int hour, int minute)
        {
            Patient.pTreated = new Time ();
            hour = hour;
            minute = minute;
        }

        //Accessor to display time in correct format 
        // There are some new local variables declared
        public String getAsString ()
        {
            int zero;
            char doubleDot;
            zero = 0;
            doubleDot = ':';
            displayTime = hour + minute;
            names = "Time is " + hour + minute;
            
            if ((hour <10) && (minute <10))
            {
                return "0" + hour + doubleDot + zero + minute;
            }
             if ((hour >10) && (minute <10))
            {
                return "" + hour + doubleDot + zero + minute;
            }
             if ((hour <10) && (minute >10))
            {
                return "0" + hour + doubleDot + minute;
            }
            else
            {
                return " " + hour + doubleDot + minute;
            }
        } 
        

 
    
    // These methods required ONLY for Task 6
    public int getElapsedTime(Time that)
    {
        int thisTime = this.getTotalMinutes();
        int thatTime = that.getTotalMinutes();
        if (thisTime > thatTime)
        {
            return thisTime - thatTime;
        }
        return thatTime - thisTime;
    }
    
    private int getTotalMinutes()
    {
        return -1;  // you must amend this code in task 6 of Cwk 3
    }
}

Any ideas how to fix this nightmare

I have no idea what to do, it keeps on saying can not find constructor Time(int, int)

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;
        public static Time pArrived;
        public static Time 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;
        }
        public void SetArrivalTime (int hour, int minute)
        { 
            SetArrivalTime(hour, minute);
        }
        
        public Patient()
        {
            super();
        }
        
        // 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;
        }
        
        
        // Mutator setting time
        // Task 2.4
        
        
        public void setArrivalTime (int hour, int minute)
        {
            pArrived = new Time (hour, minute); //error happens here
        }
        
        public void setTreatmentStart(int hour, int minute)
        {
            pTreated = new Time (hour, minute); //error happens here
        }
        
        public String getAsString()
        {
                System.out.println ("Patient Name is " + pName);
                System.out.println ("GP Name is " + gpName);
                System.out.println ("Patient Reference is " + pReference);
                System.out.println ("The Date of Birth is " + pDateD + "/" + pDateM + "/" + pDateY);
                return pName;
        }
    }

and here is my Time Class

/**
 * Handles time(hour:minutes) 
 * If given hour/minutes outside appropriate range, sets to 0
 * @author A.A.Marczyk
 * @version 22/11/06
 */

    // Fields being declared
    public class Time
    {
        private static int hour;
        private static int minute;
        public static int displayTime;
        public static String names = null;
        public static int example2;
    
        // Constrcuter resets objects
        public Time()
        {
            hour = 00;
            minute = 00;
        }
    
        // Mutator for hour field
        private void setHour (int newHour)
        {
            if (hour < 23)
            {
                hour = newHour;
            }
            else 
            { 
                hour = 0;
            }
            if (hour > 23)
            {
                System.out.println ("Please enter the right Hours?");
                hour = 0;
            }
            else
            {
                
            }
        }

        // Mutator to set minute
        private void setMinute (int newMinute)
        {
            if (newMinute <59)
            {
                minute = newMinute;
            }
            else
            {
                minute = 0;
            }
            
            if (newMinute >59)
            {
                System.out.println ("Please enter the right Minutes?");
                minute = 0;
            }
            else
            {

            }
        }
  
        // Method for reseting hours
        public void setTime (int hour,int minute)
        {
            setHour (hour);
            setMinute (minute);
        }
                
        // Constructor for time
        public void increaseTime ()
        {
            
            if (hour < 23)
            {
                hour++;
            }
            else
            {
                hour = 0;
            }
            if (minute < 59)
            {
                minute++;
            }
            else
            {
                minute = 0;
            }
        }
        
        private static void gettingTimeArrived (int hour, int minute)
        {
            Patient.pArrived = new Time ();
        }
        
         private static void gettingTreated (int hour, int minute)
        {
            Patient.pTreated = new Time ();
            hour = hour;
            minute = minute;
        }

        //Accessor to display time in correct format 
        // There are some new local variables declared
        public String getAsString ()
        {
            int zero;
            char doubleDot;
            zero = 0;
            doubleDot = ':';
            displayTime = hour + minute;
            names = "Time is " + hour + minute;
            
            if ((hour <10) && (minute <10))
            {
                return "0" + hour + doubleDot + zero + minute;
            }
             if ((hour >10) && (minute <10))
            {
                return "" + hour + doubleDot + zero + minute;
            }
             if ((hour <10) && (minute >10))
            {
                return "0" + hour + doubleDot + minute;
            }
            else
            {
                return " " + hour + doubleDot + minute;
            }
        } 
        

 
    
    // These methods required ONLY for Task 6
    public int getElapsedTime(Time that)
    {
        int thisTime = this.getTotalMinutes();
        int thatTime = that.getTotalMinutes();
        if (thisTime > thatTime)
        {
            return thisTime - thatTime;
        }
        return thatTime - thisTime;
    }
    
    private int getTotalMinutes()
    {
        return -1;  // you must amend this code in task 6 of Cwk 3
    }
}

Any ideas how to fix this nightmare

In the line which you are getting error you have used contructor of Time with two parameters (int, int) where as in your class Time your constructor Time() doesnt have input parameters. Either dont pass any parameters or if you do then create a constructor accordingly

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.