我想通过 uml/类图编写 java 代码。但我不确定它或如何为关系 0..1 到 0..1 编写它
我没有找到任何关于这种关系的信息。
1 到 0..1 是可能的,我知道如何创建它。这是我的类图,关系为 0..1 到 0..1:
我为它写了这段代码。
public class IssueWithBankStuff {
Iban Iban;
Bic bic;
Customer customer;
Date contractIban;
IssueWithOtherStuff other;
public IssueWithBankStuff() {
}
public ContractForm getContractForm() {
return other.gethContractForm();
}
public void setContractForm(ContractForm contractForm) {
other.gethContractForm(contractForm);
}
public isHolding() {
return other.isHolding();
}
public void setHolding(Boolean hold) {
other.setHolding(hold);
}
public isGeneralCorperateForm() {
return other.isGeneralCorperateForm();
}
public void setHolding(Boolean generalCorperateForm) {
other.setGeneralCorperateForm(generalCorperateForm);
}
public getStartDate() {
return other.getStartDate();
}
public void setContractForm(Date startDate) {
other.setStartDate(startDate);
}
//class specific getters and setters
}
public IssueWithOtherStuff {
ContractForm contractForm;
Boolean holding;
Boolean generalCorperateForm
Date startDate;
IssueWithBankStuff iban;
public IssueWithOtherStuff () {
}
public void setIban(Iban ib) {
iban.setIban(ib);
}
public Iban getIban () {
return iban.getIban();
}
public void setBic(Bic bic) {
iban.setBic(bic);
}
public Bic getBic () {
return iban.getBic();
}
public void setCustomer(Customer customer) {
iban.setCustomer(customer);
}
public Customer getCustomer () {
return iban.getCustomer();
}
public void setContractIban(Date contractIban) {
iban.setContractIban(contractIban);
}
public Date getContractIban () {
return iban.getContractIban();
}
//getters and setters
}