We help IT Professionals succeed at work.

Type not defined in the class

sam_2012
sam_2012 asked
on
90 Views
Last Modified: 2018-11-01
Hi Team,

I have the below error for my program . I have defined the method in the class , even then Iam getting this error

Multiple markers at this line
      - Line breakpoint:SeverityConstantsTest [line: 16] -
       main(String[])
      - Line breakpoint:SeverityConstantsTest [line: 18] -
       main(String[])
      - The method getHoursForFix(int) is undefined for the type
       SeverityUtil

Below is my code

SeverityConstants .java

package Enums;

public class SeverityConstants {
public static final int LOW=0;
public static final int MEDIUM=1;
public static final int HIGH=2;
public static final int URGENT=3;
}

===============================

SeverityUtil.java

package Enums;

public class SeverityUtil {

      public int getHoursForFix(int severity)
      {
            int hrs=0;
            
            switch (severity)
            {
            
            case SeverityConstants.LOW: hrs=24;
                                                      break;
            case SeverityConstants.MEDIUM: hrs=12;
            break;
            case SeverityConstants.HIGH: hrs=6;
            break;
            case SeverityConstants.URGENT: hrs=1;
            break;
            }            
            return hrs;            
      }      
}
=======================================

--SeverityConstantsTest.java
 
package Enums;

import java.io.Console;

public class SeverityConstantsTest {

      public static void main(String[] args) {
            // TODO Auto-generated method stub
            
            int severity=0;
            int respHrs=0;
            
            SeverityUtil sutl = new SeverityUtil();
            
            Console console= System.console();
            String str = console.readLine("Enter the Severity");
            severity=Integer.parseInt(str);
            respHrs=sutl.getHoursForFix(severity);            
            System.out.println(" The no hours for severity" + severity + " is "+ respHrs);
      }
}
Comment
Watch Question

CERTIFIED EXPERT
Top Expert 2016
Commented:
This problem has been solved!
(Unlock this solution with a 7-day Free Trial)
UNLOCK SOLUTION

Gain unlimited access to on-demand training courses with an Experts Exchange subscription.

Get Access
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Empower Your Career
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions