roman_gemini

Scala

Feb 5th, 2016
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Scala 0.51 KB | None | 0 0
  1. case class Lunch(customer: Customer, employee: Employee) {
  2.   def order(foodName: String) =
  3.     this.customer.placeOrder(foodName, employee)
  4.  
  5.   def result() = this.customer.printFood()
  6. }
  7.  
  8. case class Customer(var food: Food) {
  9.   def placeOrder(foodName: String, employee: Employee) =
  10.     this.food = employee.takeOrder(foodName)
  11.  
  12.   def printFood(): Unit = System.out.println(this.food.name)
  13. }
  14.  
  15. class Employee {
  16.   def takeOrder(foodName: String): Food = Food(foodName)
  17. }
  18.  
  19. case class Food(name: String)
Add Comment
Please, Sign In to add comment