public abstract class Human{
public String name;
public int number
public void getInfo(){
Name = JOptionPane.showInputDialog("Please enter your name: ");
money = Double.parseDouble(JOptionPane.showInputDialog("Please enter amount of money .00: "));
}
public void displayInfo(){
JOptionPane.showMessageDialog(null,"Name: "+name+"\n"+
"Number: "+number);
}
}
public class Student extends Human {
}
public class Teacher extends Human{
}
public class Janitor extends Human{
{
Hi guys, I need help if you call the getInfo () and displayInfo () methods in all three classes below. I tried:
public class Student extends Human{
public Student(){
getInfo();
displayInfo();
}
it works, but generates a warning saying "problem call in constructor". I think this is not the best way to do this.
I also tried:
@Override
public void getInfo() {
}
but if I leave it empty nothing will happen. Basically, I'm trying to call a method in an abstract class in a simple way, without introducing it into each class.
Can someone please help me! Thanks in advance.
source
share