-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Francisco Tanudjaja
committed
Aug 21, 2017
1 parent
5613773
commit f38f11b
Showing
18 changed files
with
3,296 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package week4 | ||
|
||
trait Expr { | ||
def isNumber: Boolean | ||
def isSum: Boolean | ||
def numValue: Int | ||
def leftOp: Expr | ||
def rightOp: Expr | ||
} | ||
class Number(n: Int) extends Expr { | ||
def isNumber: Boolean = true | ||
def isSum: Boolean = false | ||
def numValue: Int = n | ||
def leftOp: Expr = throw new Error("Number.leftOp") | ||
def rightOp: Expr = throw new Error("Number.rightOp") | ||
} | ||
|
||
class Sum(e1: Expr, e2: Expr) extends Expr { | ||
def isNumber: Boolean = false | ||
def isSum: Boolean = true | ||
def numValue: Int = throw new Error("Sum.numValue") | ||
def leftOp: Expr = e1 | ||
def rightOp: Expr = e2 | ||
} | ||
|
Oops, something went wrong.