Skip to content

Commit cbeda55

Browse files
author
mdodsworth
committed
adding widget and shapes scripts
1 parent 43702a7 commit cbeda55

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed

shapes-case.scala

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package shapes.cases
2+
3+
case class Point(x:Int, y:Int)
4+
5+
abstract class Shape {
6+
def draw()
7+
}
8+
9+
case class Triangle(p1:Point, p2:Point, p3:Point) {
10+
def draw() = println("triangle")
11+
}
12+
13+
case class Square(length:Int, width:Int) {
14+
def draw = println("Square")
15+
}
16+
17+
case class Circle(radius:Int, center:Int) {
18+
def draw = println("Circle")
19+
}
20+

widget3.scala

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package ui3
2+
3+
abstract class Widget {
4+
def draw():Unit
5+
override def toString() = "(Widget)"
6+
}
7+
8+
class Button(val name :String) extends Widget with Clickable {
9+
def click() = println("click!")
10+
def draw() = println("draw!")
11+
override def toString() = "(Button: " + name + ")"
12+
}
13+
14+
trait Clickable {
15+
def click():Unit
16+
}
17+

0 commit comments

Comments
 (0)