请高手帮我看一下抽象类和抽象方法。
public abstract class AbstractGuessNumber{
private int number,guess=0;
public void setNumber()
{
System.out.print("想一个数让他猜去");
this.number=getUserlnput();
}
protected abstract void showMessage(String message);
protected abstract int getUserlnput();
public void begin()
{
showMessage("欢迎玩猜数字游戏!Wn");
while(number!=guess)
{
guess=getUserlnput();
if(number<guess)
showMessage("猜小了,别泄气啊Wn");
}
showMessage("你可算猜对了Wn");
}
}import java.util.Scanner;
public class ExtendsGuessNumber extends
AbstractGuessNumber
{
private Scanner scanner;
public ExtendsGuessNumber()
{
scanner=new Scanner(System.in);
}
public void showMessage(String message)
{
for(int i=0;i<message.length()*2;i++)
{
System.out.print("*");
}
System.out.print("Wn"+message);
for (int i=0;i<message.length()*2;i++)
{
System.out.print("*");
}
System.out.print("Wn");
}
public void getUserlnput()
{
System.out.println("请输入一个数吧:");
teturn scanner.nextln();
}
}
public class Start
{
public static void main(String args[])
{
AbstractGuessNumber egu=new ExtendsGuessNumber();
egu.setNumber();
egu.begin();
}
}