- Nov 9, 2011
- 355
- 0
- 0
So, I am beginning to program in Java and I am learning accessors and modifiers. In this example, I am trying to set an employee class to where a user can input first name, last name, employee Id, and rate of pay.
Here is what I have so far. Now, I know it is not even near correct, but I am somewhat confused on what to do. I have not modified the code to use the console for input yet. Initially, for this example I just had a constructor input the code, now I want to input in via the console. I just want to get the firstname right so I can do the rest afterwards.
public class Employee {
private String firstName;
private String lastName;
private int employeeId;
private double hourlyRate;
public Employee (String firstNameIn, String lastNameIn, int idIn, double hourlyRateIn)
{
setFirstName(firstNameIn);
lastName
employeeId
hourlyRate
}
private void setFirstNameIn(String first)
{
if (first.length() > 20)
{
System.out.println("The name you entered needs to be less than 20 characters long");
System.exit(-1);
}
firstNameIn = first;
}
public String getFirstNameIn()
{
return firstNameIn;
firstnamein in the modifier says that it cannot find the symbol. So, I'm not sure why.
Any help is appreciated.
Here is what I have so far. Now, I know it is not even near correct, but I am somewhat confused on what to do. I have not modified the code to use the console for input yet. Initially, for this example I just had a constructor input the code, now I want to input in via the console. I just want to get the firstname right so I can do the rest afterwards.
public class Employee {
private String firstName;
private String lastName;
private int employeeId;
private double hourlyRate;
public Employee (String firstNameIn, String lastNameIn, int idIn, double hourlyRateIn)
{
setFirstName(firstNameIn);
lastName
employeeId
hourlyRate
}
private void setFirstNameIn(String first)
{
if (first.length() > 20)
{
System.out.println("The name you entered needs to be less than 20 characters long");
System.exit(-1);
}
firstNameIn = first;
}
public String getFirstNameIn()
{
return firstNameIn;
firstnamein in the modifier says that it cannot find the symbol. So, I'm not sure why.
Any help is appreciated.