commit 8bda4fa726bfa2a13489be329c7842109adad4b7 Author: Araozu Date: Tue Oct 31 06:08:04 2023 -0500 Scalatest diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..9e79245 --- /dev/null +++ b/.gitignore @@ -0,0 +1,32 @@ +# macOS +.DS_Store + +# sbt specific +dist/* +target/ +lib_managed/ +src_managed/ +project/boot/ +project/plugins/project/ +project/local-plugins.sbt +.history +.ensime +.ensime_cache/ +.sbt-scripted/ +local.sbt + +# Bloop +.bsp + +# VS Code +.vscode/ + +# Metals +.bloop/ +.metals/ +metals.sbt + +# IDEA +.idea +.idea_modules +/.worksheet/ diff --git a/.scalafmt.conf b/.scalafmt.conf new file mode 100644 index 0000000..643a16e --- /dev/null +++ b/.scalafmt.conf @@ -0,0 +1,4 @@ +version = "3.7.14" +runner.dialect = "scala3" +preset = default +indent.main = 4 diff --git a/README.md b/README.md new file mode 100644 index 0000000..102c5ca --- /dev/null +++ b/README.md @@ -0,0 +1,8 @@ +## sbt project compiled with Scala 3 + +### Usage + +This is a normal sbt project. You can compile code with `sbt compile`, run it with `sbt run`, and `sbt console` will start a Scala 3 REPL. + +For more information on the sbt-dotty plugin, see the +[scala3-example-project](https://github.com/scala/scala3-example-project/blob/main/README.md). diff --git a/build.sbt b/build.sbt new file mode 100644 index 0000000..f1d8ef8 --- /dev/null +++ b/build.sbt @@ -0,0 +1,12 @@ +val scala3Version = "3.3.1" + +lazy val root = project + .in(file(".")) + .settings( + name := "advent22", + version := "0.1.0-SNAPSHOT", + + scalaVersion := scala3Version, + + libraryDependencies += "org.scalameta" %% "munit" % "0.7.29" % Test + ) diff --git a/project/build.properties b/project/build.properties new file mode 100644 index 0000000..e8a1e24 --- /dev/null +++ b/project/build.properties @@ -0,0 +1 @@ +sbt.version=1.9.7 diff --git a/src/main/scala/Main.scala b/src/main/scala/Main.scala new file mode 100644 index 0000000..df448b6 --- /dev/null +++ b/src/main/scala/Main.scala @@ -0,0 +1,29 @@ +import scala.io.StdIn.readLine +import scala.util.Random + +// Number guessing game +@main def hello: Unit = + val right_answer = Random().nextInt(101) + var attempts = 0 + + println(s"Hello, you have attempts") + + while true do + attempts += 1 + print("Enter a number: ") + readLine().toIntOption match + case Some(n) if n == right_answer => + println(s"yeh, the number was $n. you win. you took $attempts attempts") + return + case Some(n) if n > right_answer => + println("you too high mah man") + case Some(n) if n < right_answer => + println("a litte too low mate") + case Some(_) => + println("??? why are you even seeing this message???") + case None => + println("that ain't a numbah. you wasted an attempt!") + + println(s"you outta attemps. you lost. the numbah was $right_answer btw") + println("kthxbye") + diff --git a/src/test/scala/MySuite.scala b/src/test/scala/MySuite.scala new file mode 100644 index 0000000..621784d --- /dev/null +++ b/src/test/scala/MySuite.scala @@ -0,0 +1,9 @@ +// For more information on writing tests, see +// https://scalameta.org/munit/docs/getting-started.html +class MySuite extends munit.FunSuite { + test("example test that succeeds") { + val obtained = 42 + val expected = 42 + assertEquals(obtained, expected) + } +}