Bai 2
Bai 2
Bai 2
import java.util.Scanner;
class Author {
String name;
String email;
char gender;
public Author(String name, String email, char gender) {
this.name=name;
this.email=email;
if(gender!='m'&&gender!='f')
System.out.println("The gender is invalid");
else
this.gender=gender;
}
public String getName() {
return name;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email=email;
}
public char getGender() {
return gender;
}
public String toString() {
return "Author[name=" + name + ",email=" + email + ",gender=" + gender
+ "]";
}
}