하위 클래스의 맨 아래에 수퍼 클래스에서 3 줄이 필요하며 switch 문을 사용하여 인쇄해야합니다. 분명히 void
이기 때문에 System.out.println(super.display());
을 인쇄하지 않습니다.수퍼 클래스에서 하위 클래스로 인쇄하려고합니다.
어떻게해야할지 모르겠습니다.
슈퍼 클래스 :
public void display()
{
String fullLocation = "";
switch (location)
{
case 'N': case 'n': fullLocation = "North London";
break;
case 'S': case 's': fullLocation = "South London";
break;
case 'E': case 'e': fullLocation = "East London";
break;
case 'W': case 'w': fullLocation = "West London";
break;
default: fullLocation = "Central London";
break;
}
System.out.println("The address of this property is at " + address + ".");
System.out.println("This property is in " + fullLocation);
System.out.println("This property has " + bedrooms + " bedrooms");
}
서브 클래스 :
public void display()
{
String buyer = purchaser;
if(sold == true){
*System.out.print(super); ???*
System.out.println("The price of this property is £" + price + ".");
System.out.println("The owner of this property is " + purchaser + ".");
}
else{
System.out.println("The startic price for this property is £" + price + ".");
System.out.println("The property is still on the Market");
}
}
고맙습니다. –