diff --git a/.idea/misc.xml b/.idea/misc.xml
index 0548357..cf25bf6 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -1,6 +1,6 @@
-
+
\ No newline at end of file
diff --git a/out/production/udemyScala/exercises/expressionExercises$.class b/out/production/udemyScala/exercises/expressionExercises$.class
index 834197e..b702726 100644
Binary files a/out/production/udemyScala/exercises/expressionExercises$.class and b/out/production/udemyScala/exercises/expressionExercises$.class differ
diff --git a/out/production/udemyScala/exercises/expressionExercises.class b/out/production/udemyScala/exercises/expressionExercises.class
index 117a83e..f6b784c 100644
Binary files a/out/production/udemyScala/exercises/expressionExercises.class and b/out/production/udemyScala/exercises/expressionExercises.class differ
diff --git a/out/production/udemyScala/lectures/part1basics/Expressions$.class b/out/production/udemyScala/lectures/part1basics/Expressions$.class
index c65c662..e912361 100644
Binary files a/out/production/udemyScala/lectures/part1basics/Expressions$.class and b/out/production/udemyScala/lectures/part1basics/Expressions$.class differ
diff --git a/out/production/udemyScala/lectures/part1basics/Expressions.class b/out/production/udemyScala/lectures/part1basics/Expressions.class
index 9c3d1b2..450a423 100644
Binary files a/out/production/udemyScala/lectures/part1basics/Expressions.class and b/out/production/udemyScala/lectures/part1basics/Expressions.class differ
diff --git a/out/production/udemyScala/lectures/part1basics/Functions$.class b/out/production/udemyScala/lectures/part1basics/Functions$.class
index 566aacd..a599a3f 100644
Binary files a/out/production/udemyScala/lectures/part1basics/Functions$.class and b/out/production/udemyScala/lectures/part1basics/Functions$.class differ
diff --git a/out/production/udemyScala/lectures/part1basics/Functions.class b/out/production/udemyScala/lectures/part1basics/Functions.class
index 74f4284..5204e0a 100644
Binary files a/out/production/udemyScala/lectures/part1basics/Functions.class and b/out/production/udemyScala/lectures/part1basics/Functions.class differ
diff --git a/out/production/udemyScala/lectures/part1basics/IsNotPrimeException$.class b/out/production/udemyScala/lectures/part1basics/IsNotPrimeException$.class
index 40bcf4c..50de499 100644
Binary files a/out/production/udemyScala/lectures/part1basics/IsNotPrimeException$.class and b/out/production/udemyScala/lectures/part1basics/IsNotPrimeException$.class differ
diff --git a/out/production/udemyScala/lectures/part1basics/IsNotPrimeException.class b/out/production/udemyScala/lectures/part1basics/IsNotPrimeException.class
index 4fda7b1..921fc8b 100644
Binary files a/out/production/udemyScala/lectures/part1basics/IsNotPrimeException.class and b/out/production/udemyScala/lectures/part1basics/IsNotPrimeException.class differ
diff --git a/out/production/udemyScala/lectures/part1basics/IsPrimeException$.class b/out/production/udemyScala/lectures/part1basics/IsPrimeException$.class
index aa6f50d..4ddd248 100644
Binary files a/out/production/udemyScala/lectures/part1basics/IsPrimeException$.class and b/out/production/udemyScala/lectures/part1basics/IsPrimeException$.class differ
diff --git a/out/production/udemyScala/lectures/part1basics/IsPrimeException.class b/out/production/udemyScala/lectures/part1basics/IsPrimeException.class
index 5aec309..6661562 100644
Binary files a/out/production/udemyScala/lectures/part1basics/IsPrimeException.class and b/out/production/udemyScala/lectures/part1basics/IsPrimeException.class differ
diff --git a/out/production/udemyScala/lectures/part1basics/Recursion$.class b/out/production/udemyScala/lectures/part1basics/Recursion$.class
index 71cf343..68a45e3 100644
Binary files a/out/production/udemyScala/lectures/part1basics/Recursion$.class and b/out/production/udemyScala/lectures/part1basics/Recursion$.class differ
diff --git a/out/production/udemyScala/lectures/part1basics/Recursion.class b/out/production/udemyScala/lectures/part1basics/Recursion.class
index 1b5c367..80dfe85 100644
Binary files a/out/production/udemyScala/lectures/part1basics/Recursion.class and b/out/production/udemyScala/lectures/part1basics/Recursion.class differ
diff --git a/out/production/udemyScala/lectures/part1basics/ValuesVariablesTypes$.class b/out/production/udemyScala/lectures/part1basics/ValuesVariablesTypes$.class
index 13f2d59..f02ac8c 100644
Binary files a/out/production/udemyScala/lectures/part1basics/ValuesVariablesTypes$.class and b/out/production/udemyScala/lectures/part1basics/ValuesVariablesTypes$.class differ
diff --git a/out/production/udemyScala/lectures/part1basics/ValuesVariablesTypes.class b/out/production/udemyScala/lectures/part1basics/ValuesVariablesTypes.class
index 15d9b9d..2c51cc5 100644
Binary files a/out/production/udemyScala/lectures/part1basics/ValuesVariablesTypes.class and b/out/production/udemyScala/lectures/part1basics/ValuesVariablesTypes.class differ
diff --git a/out/production/udemyScala/playground/JavaPlayground.class b/out/production/udemyScala/playground/JavaPlayground.class
index c3aad2b..e79b298 100644
Binary files a/out/production/udemyScala/playground/JavaPlayground.class and b/out/production/udemyScala/playground/JavaPlayground.class differ
diff --git a/out/production/udemyScala/playground/ScalaPlayground$.class b/out/production/udemyScala/playground/ScalaPlayground$.class
index 8eaa217..094ca31 100644
Binary files a/out/production/udemyScala/playground/ScalaPlayground$.class and b/out/production/udemyScala/playground/ScalaPlayground$.class differ
diff --git a/out/production/udemyScala/playground/ScalaPlayground.class b/out/production/udemyScala/playground/ScalaPlayground.class
index 022d785..f448c43 100644
Binary files a/out/production/udemyScala/playground/ScalaPlayground.class and b/out/production/udemyScala/playground/ScalaPlayground.class differ
diff --git a/src/exercises/MyList.scala b/src/exercises/MyList.scala
new file mode 100644
index 0000000..484e006
--- /dev/null
+++ b/src/exercises/MyList.scala
@@ -0,0 +1,83 @@
+package exercises
+
+abstract class MyList (val ints : Array[Int]) {
+
+ def head: Int = ints(0)
+
+ def tail = (ints.slice(1,ints.length))
+
+ def isEmpty: Boolean = ints.length == 0
+
+ def add(i: Int):Array[Int] = ints :+ i
+
+ override def toString: String = {
+ loop(ints, "(") + ")"
+ }
+
+ private def loop(rest: Array[Int], acc: String): String = {
+ if (rest.length != 1) return acc
+ else {
+ loop(rest.slice(1,rest.length) , acc + s"${rest.head}")
+ }
+
+ }
+ /*
+ implement collection
+ single linked list holds int's
+ head = first element of list
+ tail = remainder of the list
+ isEmpty = boolean
+ add(int) => new List with element added
+ override toString => a string representation of the list
+ */
+}
+
+//i'm an idiot
+
+abstract class TrueList {
+ def head: Int
+ def tail: TrueList
+ def isEmpty: Boolean
+ def add(element: Int): TrueList
+
+ //polymorphic
+ def printElements: String
+
+ override def toString: String = s"[$printElements]"
+}
+
+object Empty extends TrueList {
+ override def head: Int = throw new NoSuchElementException
+
+ override def tail: TrueList = throw new NoSuchElementException
+
+ override def isEmpty: Boolean = true
+
+ override def add(element: Int): TrueList = new Cons(element, Empty)
+
+ override def printElements: String = ""
+}
+
+
+class Cons(h: Int, t: TrueList) extends TrueList {
+ override def head: Int = h
+
+ override def tail: TrueList = t
+
+ override def isEmpty: Boolean = false
+
+ override def add(element: Int): TrueList = new Cons(element, this)
+
+ override def printElements: String = if (t.isEmpty) "" + h else s"$h ${t.printElements}"
+}
+
+
+
+object ListTest extends App {
+ val list = new Cons(1, new Cons(2, new Cons(3, Empty)))
+ println(list.tail.head)
+ println(list.add(4).head)
+ println(list.isEmpty)
+
+ println(list.toString)
+}
\ No newline at end of file
diff --git a/src/lectures/part1basics/Functions.scala b/src/lectures/part1basics/Functions.scala
index 4cf0aa0..0645285 100644
--- a/src/lectures/part1basics/Functions.scala
+++ b/src/lectures/part1basics/Functions.scala
@@ -62,7 +62,7 @@ object Functions extends App {
def isPrime(n: Int) : Boolean = {
def checkNum(m: Int) : Int = {
- if (m <= 1) throw IsPrimeException("Finished, it is prime")
+ if (m <= 1) throw IsPrimeException()
if (n % m == 0 && m != 1) throw IsNotPrimeException(m + "")
else checkNum(m-1)
}
@@ -86,6 +86,6 @@ object Functions extends App {
}
-case class IsPrimeException(value: "Finished, it is prime") extends Throwable
+case class IsPrimeException() extends Throwable
case class IsNotPrimeException(str: String) extends Throwable
diff --git a/src/lectures/part1basics/Recursion.scala b/src/lectures/part1basics/Recursion.scala
index 6a7e761..3c65562 100644
--- a/src/lectures/part1basics/Recursion.scala
+++ b/src/lectures/part1basics/Recursion.scala
@@ -52,7 +52,7 @@ object Recursion extends App {
def isPrime(n: Int) : Boolean = {
@tailrec
def checkNum(m: Int) : Int = {
- if (m <= 1) throw IsPrimeException("Finished, it is prime")
+ if (m <= 1) throw IsPrimeException()
if (n % m == 0 && m != 1) throw IsNotPrimeException(m + "")
else checkNum(m-1)
}
diff --git a/src/lectures/part2oop/AbstractDataTypes.scala b/src/lectures/part2oop/AbstractDataTypes.scala
new file mode 100644
index 0000000..6d684ec
--- /dev/null
+++ b/src/lectures/part2oop/AbstractDataTypes.scala
@@ -0,0 +1,49 @@
+package lectures.part2oop
+
+object AbstractDataTypes extends App {
+
+ // abstract
+ abstract class Animal {
+ val creatureType: String = "wild"
+ def eat: Unit
+ }
+
+ class Dog extends Animal {
+ override val creatureType: String = "Canine"
+
+ def eat: Unit = println("crunch crunch")
+ }
+
+
+ // traits
+ trait Carnivore {
+ def eat(animal: Animal): Unit
+ val preferedMeal: String = "fresh meat"
+ }
+
+
+ trait ColdBlooded
+ class Crocodile extends Animal with Carnivore with ColdBlooded {
+ override val creatureType: String = "croc"
+
+ override def eat: Unit = println("nomnomnom")
+
+ override def eat(animal: Animal): Unit = println(s"i'm a croc and i'm eating ${animal.creatureType}")
+ }
+
+ val dog = new Dog
+ val croc = new Crocodile
+ croc.eat(dog)
+
+
+
+
+ // traits vs abstract classes
+
+ // 1 traits do not have constructor parameters
+
+ // 2 can only extend 1 class, but can extend multiple traits (same class)
+
+ // 3 traits are meant to describe behavior, abstract class describes a thing
+
+}
diff --git a/src/lectures/part2oop/package.scala b/src/lectures/part2oop/package.scala
new file mode 100644
index 0000000..fceb207
--- /dev/null
+++ b/src/lectures/part2oop/package.scala
@@ -0,0 +1,8 @@
+package lectures
+
+object Inheritance extends App {
+
+
+
+
+}
diff --git a/udemyScala.iml b/udemyScala.iml
index 25bc755..775b614 100644
--- a/udemyScala.iml
+++ b/udemyScala.iml
@@ -8,5 +8,6 @@
+
\ No newline at end of file