我想实现一个测试来检查我的子类。如何在运行时测试Customer
类extends
Person
类?
import java.util.Scanner;
public class Person
{
private String name;
private String address;
private String number;
public Person() //No Argument constructor//
{
name= "";
address= "";
number= "" ;
}
public Person(String num, String nam, String add) //Explicit value constructor//
{
number= num;
name= nam;
address= add;
}
public String getName() //Accessor method//
{
return name;
}
public void setName(String name )//Mutator method//
{
this.name= name;
}
public String getAddress()
{
return address;
}
public void setAddress(String address)
{
this.address= address;
}
public String getTelephoneNumber()
{
return number;
}
public void setNumber(String number)
{
this.number= number;
}
public String toString ()
{
return name + "\n" + address + "\n" + number;
}}
public class Customer extends Person
{
public Customer(String num, String nam, String add)
{
super (num, nam, add);
}
public boolean checkResponse( char response)
{
if (response == 'Y'){return true;}
return false;
}
public void display()
{
System.out.println(super.toString());
}
}