0

plese help..what is the poblem about this codes?\

public abstract class Employee{
	private String firstName;
	private String lastName;
	private String socialSecurityNumber;
	public Employee(String first, String last, String ssn){
		firstName=first;
		lastName=last;
		socialSecurityNumber=ssn;
	}
	public void setFirstName(String first){
		firstName=first;
	}
	public String getFirstName(){
		return firstName;
	}
	public void setLastName(String last){
		lastName=last;
	}
	public String getLastName(){
		return lastName;
	}
	public void setSocialSecurityNumber(String ssn){
		socialSecurityNumber=ssn;
	}
	public String getSocialSecurityNumber(){
		return socialSecurityNumber;
	}
	public String toString(){
		return String.format(" %s %s \n social security number: %s ", getFirstName(), getLastName(), getSocialSecurityNumber());
	}
	public abstract double earnings();
}
3
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by tiny7415
1

Nothing... if you are wondering why you can't create an object from this code it's because you declared it as abstract. Otherwise it seems fine to me...

0

I think you need to rewrite your toString() method and kvass is right take the abstract off to your class otherwise everything is fine.
if i will rewrite it .. it will be

public class Employee{.....

public String toString(){
return String.format(" %s %s \n social security number: %s ", firstName, lastName, socialSecurityNumber);
}

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.