public class Employee
{

	private String name;
	private String number;
	private boolean valid=true;


	public Employee(String nm, String num)
	{
		name=nm;
		number=num;

		if(number.length()!=5)
		valid=false;
		for(int i=0; i<3; i++)
		{
			if(!Character.isDigit(number.charAt(i)))
			valid=false;
		}

		if(number.charAt(3)!='-')
		valid=false;

		if(!Character.isLetter(number.charAt(4)))
		valid=false;
		else
		{
			if(number.charAt(4)!='A'||number.charAt(4)!='B'||number.charAt(4)!='C'||number.charAt(4)!='D'||number.charAt(4)!='E'||
			number.charAt(4)!='F'||number.charAt(4)!='G'||number.charAt(4)!='H'||number.charAt(4)!='I'||number.charAt(4)!='J'||
			number.charAt(4)!='K'||number.charAt(4)!='L'||number.charAt(4)!='M')
			valid=false;
		}
	}

	public boolean getNum()
	{
		return valid;
	}



}
public class work extends Employee
{
	private int shift;

	public work(int sh)
	{
		shift=sh;
	}
}

when i try to compile the work class, there is an error:
C:\Documents and Settings\1234\My Documents\java\textpad\lab10\work.java:6: cannot find symbol
symbol : constructor Employee()
location: class Employee
{
^
1 error

isit anything wrong with my code?
pls help.
thanks
Add to rayda's Reputation

Here's why: when you create a subclass, and you write a subclass constructor, and in that constructor you do not have a call to the superclass constructor as the first statement, the Java compiler puts in a call to super() by default (in order to ensure that everything inherited from the superclass is initialised). In your superclass you have a constructor, but not a default constructor (ie public Employee() ).
I guess that when you create a work (ps should be Work) they should still have a name & number, because they are Employees, so maybe the constructor should be something like

public work(int sh, String nm, String num){
    super(nm, num);
    shift=sh;
}
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.