0
Help me with my best code i could't find where are the errors?
what I did wrong public class Program { public static void main(String[] args) { Program me = new hassan(); Program him = new amin () ; me.boy(); him.mama(); } } import java.util.*; public class hassan extends Program { public static boy (System.in) { int boy ; return boy; } } public class amin extends Program { public void mama() { System.out.println ("hay mom") ; } }
4 odpowiedzi
+ 2
instead do it like this..
import java.util.*;
public class Program
{
public static void main(String[] args) {
hassan me = new hassan();
amin him = new amin() ;
me.boy(System.in.nextInt());
him.mama();
}
}
public class hassan {
public hassan (){}
public static int boy (int x) {
int boy = x;
return boy;
}
}
public class amin {
public amin(){}
public void mama() {
System.out.println ("hay mom") ;
}
}
+ 1
thanks a lot man
+ 1
but there is something wrong with your code pls check it out and tell me what is the answer and again thank you for your help thanks a lot man
0
yeash there was a problem... I modified it as follows. I tested it and it works fine
You can check it here in playground or....
https://code.sololearn.com/cz3h7UUvHhJ0/?ref=app
or just look this one
import java.util.*;
public class Program
{
public static void main(String[] args) {
hassan me = new hassan();
amin him = new amin() ;
Scanner scan = new Scanner(System.in);
him.mama();
System.out.print( me.boy(scan.next()) );
}
}
public class hassan {
public hassan (){}
public static String boy (String x) {
String boy = "I\'m "+x;
return boy;
}
}
public class amin {
public amin(){}
public void mama() {
System.out.print("hay mom, ") ;
}
}