我是Java编程的初学者,明天要考试,但是还是看不懂抽象类,因为每一个都给我无穷无尽的错误,我看书和上网,但我对自己感到很失望。
好吧,这是我最近的练习:应该是祝贺周年纪念日!
这是抽象基类
abstract class Pessoa
{
private int dia, mes, ano;
Pessoa (int dia, int mes, int ano)
{
this.dia = dia;
this.mes = mes;
this.ano = ano;
}
public void setDia(int dia){ this.dia = dia;}
public void setMes(int mes){ this.mes = mes;}
public void setAno(int ano){ this.ano = ano;}
public int getDia(){return dia;}
public int getMes(){ return mes;}
public int getAno(){ return ano;}
abstract int aniversario();
}
这个是继承方法的派生类
import java.util.Date;
class Cliente extends Pessoa
{
int aniversario()
{
int d = data.get(Calendar.DAY_OF_MONTH);
int m = data.get(Calendar.MONTH);
if ( d== dia && m == mes)
return "Parabéns pelo seu aniversário! ";
}
}
错误是:
constructor Pessoa in class Pessoa cannot be applied to given types;
required: java.lang.String,int,java.lang.String,int,int,int
found: no arguments
reason: actual and formal argument lists differ in length
the operator that you use cannot be used for the
type of value you are using it for. You are either
using the wrong type here, or the wrong operator.
也许很明显,但我看不到!(请,对不起英语不好)