And I do have this question, any help would be appreciated. The problem is that I don't have an idea where I'm wrong.
public class Author { //opening statement
private String name;
private String email;
private char gender;
private char m, f;
//constructors (overloaded)
public Author(){ //1st constructor
name = "John Smith";
email = "John.smith@yahoo.com";
gender = m;
}
public Author(String n){
name = n;
email = "John.smith@yahoo.com";
gender = m;
}
public Author(String n, String e){
name = n;
email = e;
gender = m;
}
public Author(String n, String e, char g){
name = n;
email = e;
gender = g;
}
//public methods
public void setEmail(String email) {
this.email = email;
}
public String getName() {
return name;
}
public String getEmail() {
return email;
}
public char getGender() {
return gender;
}
public String toString() {
return name + "(" + gender + ") " + "at " + email;
}
} //closing statement
Here is the other code:
public class TestAuthor { //save as TestAuthor.java
public static void main(String[] args){
Author a1 = new Author();
System.out.println(a1.name + "("
+ a1.gender + ") " + "at " + a1.email);
} //main closing statement
} //class closing statement
The errors are:
The field foo: is not visible for my 3 private variables.
Procedures done: Already searched for the problem in google:
Supposed answers:
-It's not in the right package (I think it is)
Advice would be of great help. Thank you.