Hello, I have problem with inheritance , when I try to run the program , I get
PHP Code:
Enter the frist and last name of student
dd
dd
dd
dd dd
not the full name ?
3 strings
the main method
PHP Code:
public static void main(String[] args) {
Scanner in = new Scanner (System.in);
System.out.println("Enter the frist and last name of student" );
String inf=in.nextLine();
String infs=in.nextLine();
String infss=in.nextLine();
NewClass account= new NewClass(inf,infs,infss);
System.out.print(account);
} // end main
the class method
PHP Code:
public class Account {
private String name1;
private String name2;
public Account(String a1 ,String a2 ) {
name1=a1;
name2=a2;
}
public void setName1(String a1){
name1=a1;
}
public void setName2(String a2){
name2=a2;
}
public String getName1(){
return name1;
}
public String getName2(){
return name2;
}
public String toString(){
return String.format("%-1s %s ",name1, name2);
}
and the class inheritance method
PHP Code:
public class NewClass extends Account {
private String name3;
public NewClass(String name1,String name2,String name33){
super(name1,name2);
getstring(name33);
}
public void getstring(String name33){
name3=name33;
}
public String getString(){
return name3;
}
public String forstring(){
return String.format(" %s just to know if it works ",super.toString(),name3 );
}
what should I do to fix this problem ??