我之前发过一个问题,但我无法得到明确的答案。我在为学校作业绘制序列图时遇到了麻烦。我一直在谷歌搜索SD,但没有详细的深入教程。 我在这里要做的是为某些功能创建SD,具体为三,我希望在提交之前检查我的图纸。我发布了一个序列图,后面是用JAVA编写的代码。
post.makePayment(); // this is called first.
============================================
public class POST {
private Store store;
private ProductCatalog catalog;
private Sale sale = null;
public POST(Store store, ProductCatalog catalog) {
this.store = store;
this.catalog = catalog;
}
public void enterItem(int upc, int qty) {
if (sale == null) {
Date date = new Date(System.currentTimeMillis());
sale = new Sale(date);
}
ProductSpec s = catalog.spec(upc);
sale.makeLineItem(s, qty);
}
public void makePayment() {
if (sale != null) sale.makePayment();
}
public void endSale() {
store.addCompleteSale(sale);
sale = null;
}
} // This is the class POST.
==========================================================
public class Store {
protected ArrayList<Sale> completedSales = null;
public Store() {
completedSales = new ArrayList<Sale>();
}
public void addCompleteSale(Sale sale) {
completedSales.add(sale);
}
} // the class Store.
此外,我对如何处理指向的函数感到困惑...(?) 例如,就像那个 post.endSale() 我知道TestPOS中的主体正在调用类POST中定义的函数,实例帖是特定的,但是我应该在哪里绘制序列图中的endSale()行?