別のクラスからメソッドを呼び出す必要がありますが、これに問題があります。把握しにくい。落札者の名前を表示する必要があります。if部分に入札値が記載されたprintlnに注意してください。
ガイドライン: PersonクラスのgetNameメソッドを使用する必要があります。まず、Personクラスのオブジェクトを取得する必要があります。これを行うには、highestBidオブジェクトを使用し、getBidderメソッドを呼び出します。Personオブジェクトを返します。そのオブジェクトを使用して、getName()メソッドを呼び出します。
これが私のコードです:
public void close(int lotNumber, String description)
{
for(Lot lot : lots)
{
System.out.println(lotNumber + description); //print lot number and description.
Bid highestBid = lot.getHighestBid(); //get the highest bid for the lot.
if (highestBid != null)
{
System.out.println(bidder + highestBid.getValue()); //print bidder and highest bid value
}
else
{
System.out.println("Not sold"); //if not sold print "Not sold"
}
}
}
ありがとうございました。