This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Customer { | |
String name; | |
} | |
class Order { | |
String orderId; | |
Customer customer; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static void main(String... args) { | |
class Customer { | |
String name; | |
} | |
class Order { | |
String orderId; | |
Customer customer; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Customer { | |
String name; | |
} | |
class Order { | |
String orderId; | |
Customer customer; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Customer { | |
String name; | |
} | |
class Order { | |
String orderId; | |
Customer customer; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class OrderManager { | |
double getTotalPrice(Order order) { | |
//... | |
for (Item item : order.getItems()) { | |
//... | |
} | |
return num; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class OrderManager { | |
double getTotalPrice(Order order) { | |
//... | |
for (Item item : order.getItems()) { | |
//... | |
} | |
return num; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Order { | |
Item[] items; | |
String orderId; | |
Customer customer; | |
void addItem(Item item) { | |
} | |
double getTotalPrice() { | |
//... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class OrderManager { | |
Map<Order, Double> prices; | |
double getTotalPrice(Order order) { | |
if (prices.containsKey(order)) { | |
return prices.get(order); | |
} | |
for (Item item : order.getItems()) { | |
//... | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Order { | |
Item[] items; | |
String orderId; | |
Customer customer; | |
Double totalPrice; | |
void addItem(Item item) { | |
//... | |
totalPrice = null; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
String orderId = request.getParam("id"); | |
String sku = request.getParam("sku"); | |
Order order = orderDao.findOneById(orderId); | |
Item item = itemDao.findOneBySku(sku); | |
order.addItem(item); | |
double total = 0.0; | |
for (Item item : order.getItems()) { | |
total += item.getPrice(); |
OlderNewer