/*
 * Main.scala
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package calc


object Main {
    def main(args : Array[String]) : Unit = {
        val ted = Person("Ted", "Neward", 37)
        val ted2 = Person("Ted", "Neward", 37)
        val amanda = Person("Amanda", "Laucher", 27)

        Console.println("ted == amanda: " +
                        (if (ted == amanda) "Yes" else "No"))
        Console.out.println("ted == ted: " +
                            (if (ted == ted) "Yes" else "No"))
        Console.out.println("ted == ted2: " +
                            (if (ted == ted2) "Yes" else "No"))

        Console.println(process(ted))
        Console.println(process(amanda))
    }

    def process(p : Person) = {
        "Processing " + p + " reveals that" +
        (p match {
                case Person(_, _, a) if a > 30 =>
                    " they're certainly old."
                case Person(_, "Neward", _) =>
                    " they come from good genes...."
                case Person(first, last, ageInYears) if ageInYears > 17 =>
                    " " + first + " " + last + " is " + ageInYears + " years old."
                case _ =>
                    " I have no idea what to do with this person"
            })
    }

}
