How to use composition from another class to set Name?
Posted
by
user1874549
on Stack Overflow
See other posts from Stack Overflow
or by user1874549
Published on 2012-12-11T05:01:32Z
Indexed on
2012/12/11
5:03 UTC
Read the original article
Hit count: 103
I have some of the code here. I am trying to use one class to reference another so I may obtain the first name of the person. I want the firstName in main class to work but IDE mentions the variable isn't found. Will replacing 'first' with 'firstName' work?
Main class:
public BasePlusCommissionEmployee( String first, String last,
String ssn, double sales, double rate, double salary) {
cE = new CommissionEmployee( first, last, ssn, sales, rate );
setBaseSalary( salary );
}
public void setFirstName(String firstName) {
// Trying to get this to work...
cE.setFirstName(first);
}
SubClass:
private String firstName;
public void setFirstName( String first )
{
firstName = first;
}
© Stack Overflow or respective owner