I
idaku2
Hi all!
Suppose I have this two classes:
class ShoppingCart {
addBook(Book book){}
removeBook(Book book) {}
getPrice()
buy()
....
}
and
class Buyer {
private ShoppingCart cart;
spendMoney()
buy();
....
}
When shoppingCart's buy() is called, cart must remove all of it's
books, and the caller gets the price of the books. What is the proper
design here: should buyer know in which order class ShoppingCart works
(cart.getPrice, cart.buy() in which cart remove all the books), or
should buyer call cart.buy, cart.getPrice (order again), and then
buyer would remove all the books through for loop, or should I use
somethin like this
cart.buy(Buyer buyer), and inside cart.buy cart calls
buyer.spendMoney()?
Thanks in advance
Suppose I have this two classes:
class ShoppingCart {
addBook(Book book){}
removeBook(Book book) {}
getPrice()
buy()
....
}
and
class Buyer {
private ShoppingCart cart;
spendMoney()
buy();
....
}
When shoppingCart's buy() is called, cart must remove all of it's
books, and the caller gets the price of the books. What is the proper
design here: should buyer know in which order class ShoppingCart works
(cart.getPrice, cart.buy() in which cart remove all the books), or
should buyer call cart.buy, cart.getPrice (order again), and then
buyer would remove all the books through for loop, or should I use
somethin like this
cart.buy(Buyer buyer), and inside cart.buy cart calls
buyer.spendMoney()?
Thanks in advance