プログラムで別のクラスからプライベート変数を入力したい。
ミューテーターとアクセサーを使いたい。
NullPointerException のエラーが発生し続けます。私のコードの問題は何ですか?
public abstract class Inputs {
private String val;
private String typ;
public abstract void setVal(String val);
public abstract void setTyp(String typ);
public abstract String getVal();
public abstract String getTyp();
}
public DeckOfCards extends Inputs{
String val;
String typ;
static DeckOfCards kerds = new DeckOfCards();
public void setVal(String val){
this.val = val;
}
public void setTyp(String typ){
this.typ = typ;
}
public String getVal(){
return this.val;
}
public String getTyp(){
return this.typ;
}
public static void main(String args[]){
System.out.print("Value: ");
kerds.setVal(kerds.val);
if(kerds.val.equals("A"){
System.out.print("Type: ");
kerds.setTyp(kerds.typ);
}
}
}