请高手帮我看一下这题抽象类和抽象方法哪里出错帮我修改出来谢谢。
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();
}
}
----------------解决方案--------------------------------------------------------
是什么问题呀,老兄,把问题贴出来呀?
----------------解决方案--------------------------------------------------------
这么复杂 我才刚刚学 收藏该帖子 下次来学习
----------------解决方案--------------------------------------------------------
public void getUserlnput()
{
System.out.println("请输入一个数吧:");
teturn scanner.nextln();
}
你这个方法一看就写错了,是 return scanner.nextInt();并且把void要改成 int
----------------解决方案--------------------------------------------------------