Results 1 to 4 of 4
Thread: what's wrong?
- 04-14-2009, 08:32 PM #1
Member
- Join Date
- Mar 2009
- Posts
- 7
- Rep Power
- 0
what's wrong?
Java Code: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; } }when i try to compile the work class, there is an error:Java Code:public class work extends Employee { private int shift; public work(int sh) { shift=sh; } }
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
- 04-14-2009, 08:36 PM #2
you're missing a default constructor within Employee
I think it's either that or your employee class isnt located in the same file as your work class.Java Code:public Employee(){ this.name = "name"; this.number = 0; }Liberty has never come from the government.
Liberty has always come from the subjects of government.
The history of liberty is the history of resistance.
The history of liberty is a history of the limitation of governmental power, not the increase of it.
- 04-14-2009, 08:43 PM #3
Member
- Join Date
- Mar 2009
- Posts
- 7
- Rep Power
- 0
I put both class file under the same folder.
then, I have try to change the default constructor as you said, but I still get the same error.
why it will like that?..
- 04-14-2009, 09:07 PM #4
Senior Member
- Join Date
- Sep 2008
- Posts
- 564
- Rep Power
- 5
Similar Threads
-
what wrong
By pro85 in forum New To JavaReplies: 3Last Post: 02-09-2009, 01:07 PM -
What did i do wrong
By jpnym15 in forum New To JavaReplies: 8Last Post: 11-17-2008, 10:07 AM -
So, what am I doing wrong?
By Charles_Smith in forum New To JavaReplies: 0Last Post: 10-29-2008, 02:50 PM -
right or wrong
By jot321 in forum New To JavaReplies: 7Last Post: 09-25-2008, 11:45 AM -
Can someone tell me what I did wrong??
By booter4429 in forum New To JavaReplies: 7Last Post: 08-13-2008, 08:35 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks