Exercice 1:
Propose a class diagram relating to the following code (Reverse Engineering)
public class Advertiser {
private Set accounts;
public Advertiser() {
accounts = new HashSet();
}
public void addAccount (Account a) {
accounts.add(a);
a.setOwner(this);
}
public void removeAccount (Account a)
{
accounts.remove(a);
a.setOwner(null);
}
}
public class Account {
private Advertiser owner;
public void setOwner (Advertiser
newOwner) {
if (owner != newOwner) {
Advertiser old = owner;
owner = newOwner;
if (newOwner != null)
newOwner.addAccount(this);
if (oldOwner != null)
old.removeAccount(this);
}
}
}
Exercice 2:
Translate into java the following UML class diagram.
PizzaBoom
- quantitySold: integer[]
+ PizzaBoom (size: integer)
+ sellPizza(var: string, sze: integer, nbsold:
integer)
+ logSales(fileName: string)
+ displaySalesFromFile(fileName: string)
+ storeInObjectFile(fileName: string)
+ displayMenuBySizeFromFile(fileName:
string, minSize: integer)
Pizza
-menu
1..n
variety: string
size: integer
+ Pizza(var: string, sze: integer)