この toString メソッドをセットアップしました
public String toString (){
String result;
result = "Ideal Family";
result += "\n"+person1.toString();
result += "\n"+person2.toString();
result += "\n"+person3.toString();
result += "\n"+person4.toString();
result += "\n"+pet1.toString();
result += "\n"+car1.toString();
result += "\n"+car2.toString();
result += "\n"+homeAddress.toString();
return result;
}
出力したい順序でオブジェクトをリストします。オブジェクト内の値に基づいてリストを並べ替える方法はありますか。具体的には、Person クラスで、インスタンス変数 int に基づいて person オブジェクトを並べ替えます。
Person クラスはこれらのパラメータを取ります
public Person (String personName,String personGender,String personSS,int personAge){
name = personName;
ss = personSS;
age = personAge;
gender = personGender;
}