marking1/drumb_test7.scala
author Christian Urban <christian.urban@kcl.ac.uk>
Sat, 11 Mar 2023 23:09:51 +0000
changeset 465 8ce150207792
parent 331 e3878cdd38bc
permissions -rw-r--r--
updated to scala 3
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
281
87b9e3e2c1a7 updated
Christian Urban <urbanc@in.tum.de>
parents: 268
diff changeset
     1
/*
268
e43f7e92ba26 updated
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
     2
def myassert(cond : => Boolean) = {
e43f7e92ba26 updated
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
     3
  try {
e43f7e92ba26 updated
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
     4
    assert(cond)
e43f7e92ba26 updated
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
     5
  } catch { 
e43f7e92ba26 updated
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
     6
    case _ : Throwable => System.exit(1)
e43f7e92ba26 updated
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
     7
  }
e43f7e92ba26 updated
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
     8
}
281
87b9e3e2c1a7 updated
Christian Urban <urbanc@in.tum.de>
parents: 268
diff changeset
     9
*/
268
e43f7e92ba26 updated
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
    10
281
87b9e3e2c1a7 updated
Christian Urban <urbanc@in.tum.de>
parents: 268
diff changeset
    11
assert(CW6b.investment(List("GOOG", "AAPL", "BIDU"), 2000 to 2000, 100) == 100)
87b9e3e2c1a7 updated
Christian Urban <urbanc@in.tum.de>
parents: 268
diff changeset
    12
assert(CW6b.investment(List("GOOG", "AAPL", "BIDU"), 2000 to 2001, 100) == 27)
87b9e3e2c1a7 updated
Christian Urban <urbanc@in.tum.de>
parents: 268
diff changeset
    13
assert(CW6b.investment(List("GOOG", "AAPL", "BIDU"), 2000 to 2002, 100) == 42)
87b9e3e2c1a7 updated
Christian Urban <urbanc@in.tum.de>
parents: 268
diff changeset
    14
assert(CW6b.investment(List("GOOG", "AAPL", "BIDU"), 2000 to 2003, 100) == 27)
87b9e3e2c1a7 updated
Christian Urban <urbanc@in.tum.de>
parents: 268
diff changeset
    15
assert(CW6b.investment(List("GOOG", "AAPL", "BIDU"), 2000 to 2004, 100) == 38)
331
e3878cdd38bc updated
Christian Urban <urbanc@in.tum.de>
parents: 281
diff changeset
    16
e3878cdd38bc updated
Christian Urban <urbanc@in.tum.de>
parents: 281
diff changeset
    17
// 113
e3878cdd38bc updated
Christian Urban <urbanc@in.tum.de>
parents: 281
diff changeset
    18
assert((112 to 114).contains(CW6b.investment(List("GOOG", "AAPL", "BIDU"), 2000 to 2005, 100)))
e3878cdd38bc updated
Christian Urban <urbanc@in.tum.de>
parents: 281
diff changeset
    19
// 254
e3878cdd38bc updated
Christian Urban <urbanc@in.tum.de>
parents: 281
diff changeset
    20
assert((252 to 256).contains(CW6b.investment(List("GOOG", "AAPL", "BIDU"), 2000 to 2006, 100)))
e3878cdd38bc updated
Christian Urban <urbanc@in.tum.de>
parents: 281
diff changeset
    21
// 349
e3878cdd38bc updated
Christian Urban <urbanc@in.tum.de>
parents: 281
diff changeset
    22
assert((346 to 352).contains(CW6b.investment(List("GOOG", "AAPL", "BIDU"), 2000 to 2007, 100)))
e3878cdd38bc updated
Christian Urban <urbanc@in.tum.de>
parents: 281
diff changeset
    23
//11504
e3878cdd38bc updated
Christian Urban <urbanc@in.tum.de>
parents: 281
diff changeset
    24
assert((11389 to 11619).contains(CW6b.investment(List("GOOG", "AAPL", "BIDU"), 1990 to 2017, 100)))