DVD と主役のオブジェクトを 2 つの異なるクラスから表示できるようにする小さなアプリケーションに取り組んでいますが、次の出力が得られます。
person.Person@10ed7f5c
誰が私が間違っているのかについての洞察を提供できますか?
DVDクラス
public class DVD {
private String title;
private Person leadActor;
private int noOfStars;
public DVD (String a,Person person, int b) {
title = a;
leadActor = person;
noOfStars = b;
}
public String getTitle(){
return title;
}
public void setTitle(String title){
this.title = title;
}
public Person getLeadActor(){
return leadActor;
}
public void setLeadActor(Person leadActor){
this.leadActor = leadActor;
}
public int getNoOfStars(){
return noOfStars;
}
public void setNoOfStarts(int noOfStars){
this.noOfStars = noOfStars;
}
@Override
public String toString() {
String s = "Title " + title + "/r" + "Actor:" + leadActor + "/r" + noOfStars;
return s;
}
}
人物クラス
public class Person {
private String firstName;
private String lastName;
public Person (String a, String b){
firstName = a;
lastName = b;
}
public String getfirstName(){
return firstName;
}
public void setfirstName(String firstName){
this.firstName = firstName;
}
public String getlastName(){
return lastName;
}
public void setlastName(String lastName){
this.lastName = lastName;
}
}
そして、オブジェクトを作成してtoStringを呼び出す私のクラス
public class DvdTest {
private DVD d1;
public static void main (String [] args){
Person p2 = new Person ("Leonardo", "Decaprio");
DVD d1 = new DVD ("Inception",p2,4);
System.out.println (p2.toString());
}
}