我在 Name 类中创建了一个 Name 对象,在 Address 类中创建了一个 Address 对象。我可以结合这两个对象在 MailingLabel 类中创建一个 MailingLabel 对象吗?头等舱public class Name { private String firstName; private char middleInitial; private String lastName; public Name (String fn, char mi, String ln) { firstName = fn; middleInitial = mi; lastName = ln; }二等舱public class Address { private int streetNumber; private String streetName; private String streetType; private String city; private String state; private int zip; public Address (int snum, String sn, String st, String c, String s, int z) { streetNumber = snum; streetName = sn; streetType = st; city = c; state = s; zip = z; }MailingLabel 的目标是打印出一个看起来像 Millicent X Feniwick 1600 Huckleberry Lane Chelsea, NJ 15483
1 回答
30秒到达战场
TA贡献1828条经验 获得超6个赞
public class MailingLabel{
private Address addressname;
private Name theName;
public MailingLabel(Address addressname, Name theName){
this.addressname = addressname;
this.theName = theName;
}
}
根据您的要求,我想这就是您所需要的。
添加回答
举报
0/150
提交
取消