fork download
  1. case class Developer(id: Int, name: String, email: String) {
  2. def rates(p: Project) = Rating(this, p, 0)
  3. }
  4. case class Project(uid: String, ratings: List[Rating])
  5. case class Rating(dev: Developer, proj: Project, rating: Int) {
  6. def by(stars: Int) = Rating(dev, proj, stars)
  7. def line = s"${dev.name} gave ${proj.uid} $rating stars"
  8. }
  9.  
  10. object Main extends App {
  11. val rodolfo = Developer(1, "John", "john@example.com")
  12. val jquery = Project("jquery/jquery", Nil)
  13. val rating = rodolfo rates jquery by 5
  14.  
  15. println(rating.line)
  16. }
Success #stdin #stdout 0.4s 382016KB
stdin
Standard input is empty
stdout
John gave jquery/jquery 5 stars