Updated samples
This commit is contained in:
parent
f786df548d
commit
f299d0943e
|
@ -1,5 +1,5 @@
|
|||
// BuildingMaps/AssociateBy.kt
|
||||
package buildmaps
|
||||
package buildingmaps
|
||||
import atomictest.eq
|
||||
|
||||
fun main() {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// BuildingMaps/AssociateByUnique.kt
|
||||
package buildmaps
|
||||
package buildingmaps
|
||||
import atomictest.eq
|
||||
|
||||
fun main() {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// BuildingMaps/AssociateWith.kt
|
||||
package buildmaps
|
||||
package buildingmaps
|
||||
import atomictest.eq
|
||||
|
||||
fun main() {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
// BuildingMaps/ColorBlend.kt
|
||||
package buildmaps
|
||||
package buildingmaps
|
||||
import atomictest.eq
|
||||
import buildmaps.Color.*
|
||||
import buildingmaps.Color.*
|
||||
|
||||
fun blend(a: Color, b: Color): Color = when {
|
||||
a == b -> a
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// BuildingMaps/FilterMap.kt
|
||||
package buildmaps
|
||||
package buildingmaps
|
||||
import atomictest.eq
|
||||
|
||||
fun main() {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// BuildingMaps/GetOrPut.kt
|
||||
package buildmaps
|
||||
package buildingmaps
|
||||
import atomictest.eq
|
||||
|
||||
fun main() {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// BuildingMaps/GroupBy.kt
|
||||
package buildmaps
|
||||
package buildingmaps
|
||||
import atomictest.eq
|
||||
|
||||
fun main() {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// BuildingMaps/GroupByVsFilter.kt
|
||||
package buildmaps
|
||||
package buildingmaps
|
||||
import atomictest.eq
|
||||
|
||||
fun main() {
|
||||
|
|
|
@ -1,13 +1,14 @@
|
|||
// BuildingMaps/ImmutableBlendMap.kt
|
||||
@file:OptIn(ExperimentalStdlibApi::class)
|
||||
package buildmaps
|
||||
package buildingmaps
|
||||
|
||||
class BlendMap {
|
||||
val map: Map<Pair<Color, Color>, Color> =
|
||||
buildMap {
|
||||
for (a in Color.values()) {
|
||||
for (b in Color.values()) {
|
||||
this[a to b] = buildmaps.blend(a, b)
|
||||
this[a to b] =
|
||||
buildingmaps.blend(a, b)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// BuildingMaps/PaintColors.kt
|
||||
package buildmaps
|
||||
package buildingmaps
|
||||
|
||||
enum class Color {
|
||||
Red, Blue, Yellow, Purple,
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// BuildingMaps/People.kt
|
||||
package buildmaps
|
||||
package buildingmaps
|
||||
|
||||
data class Person(
|
||||
val name: String,
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// BuildingMaps/SimilarOperation.kt
|
||||
package buildmaps
|
||||
package buildingmaps
|
||||
import atomictest.eq
|
||||
|
||||
fun main() {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// BuildingMaps/TransformingMap.kt
|
||||
package buildmaps
|
||||
package buildingmaps
|
||||
import atomictest.eq
|
||||
|
||||
fun main() {
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
// FoldingLists/FoldAndReduce.kt
|
||||
package foldinglists
|
||||
import atomictest.eq
|
||||
|
||||
fun main() {
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
// FoldingLists/FoldRight.kt
|
||||
package foldinglists
|
||||
import atomictest.eq
|
||||
|
||||
fun main() {
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
// FoldingLists/FoldVsForLoop.kt
|
||||
package foldinglists
|
||||
import atomictest.eq
|
||||
|
||||
fun main() {
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
// FoldingLists/SumViaFold.kt
|
||||
package foldinglists
|
||||
import atomictest.eq
|
||||
|
||||
fun main() {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
## Folding Lists (#4)
|
||||
|
||||
The starter code provides a `Condition` class and a function
|
||||
`Condition.combine()` which combines two conditions. There's also a skeleton
|
||||
for the `List<Condition>` extension function `combineAll()` which combines all
|
||||
`Condition.combine()` that combines two conditions. There's also a skeleton
|
||||
for the `List<Condition>` extension function `combineAll()` that combines all
|
||||
the conditions in the `List`. Complete the implementation using `reduce()`,
|
||||
assuming the `List` is non-empty.
|
|
@ -1,4 +1,5 @@
|
|||
// HigherOrderFunctions/Any.kt
|
||||
package higherorderfunctions
|
||||
import atomictest.eq
|
||||
|
||||
fun <T> List<T>.any( // [1]
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
// HigherOrderFunctions/NullableFunction.kt
|
||||
package higherorderfunctions
|
||||
import atomictest.eq
|
||||
|
||||
fun main() {
|
||||
|
@ -6,7 +7,7 @@ fun main() {
|
|||
{ null }
|
||||
val mightBeNull: ((String) -> Int)? = null
|
||||
returnTypeNullable("abc") eq null
|
||||
// Won't compile without a null check:
|
||||
// Doesn't compile without a null check:
|
||||
// mightBeNull("abc")
|
||||
if (mightBeNull != null) {
|
||||
mightBeNull("abc")
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
// HigherOrderFunctions/NullableReturn.kt
|
||||
package higherorderfunctions
|
||||
import atomictest.eq
|
||||
|
||||
fun main() {
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
// HigherOrderFunctions/RepeatByInt.kt
|
||||
package higherorderfunctions
|
||||
|
||||
fun main() {
|
||||
repeat(2) { println("hi!") }
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// HigherOrderFunctions/RepeatFun.kt
|
||||
package definingrepeat
|
||||
package higherorderfunctions
|
||||
|
||||
fun repeat(
|
||||
times: Int,
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
// HigherOrderFunctions/RepeatVerbose.kt
|
||||
package higherorderfunctions
|
||||
|
||||
fun main() {
|
||||
repeat(2, { println("hi!") })
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
// HigherOrderFunctions/SimpleOperation.kt
|
||||
package higherorderfunctions
|
||||
import atomictest.eq
|
||||
|
||||
fun main() {
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
// HigherOrderFunctions/TypeDeclarations.kt
|
||||
package higherorderfunctions
|
||||
import atomictest.eq
|
||||
|
||||
fun main() {
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
// Lambdas/BasicLambda.kt
|
||||
package lambdas
|
||||
import atomictest.eq
|
||||
|
||||
fun main() {
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
// Lambdas/JoinToString.kt
|
||||
package lambdas
|
||||
import atomictest.eq
|
||||
|
||||
fun main() {
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
// Lambdas/LambdaAndNamedArgs.kt
|
||||
package lambdas
|
||||
import atomictest.eq
|
||||
|
||||
fun main() {
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
// Lambdas/LambdaIt.kt
|
||||
package lambdas
|
||||
import atomictest.eq
|
||||
|
||||
fun main() {
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
// Lambdas/LambdaTypeInference.kt
|
||||
package lambdas
|
||||
import atomictest.eq
|
||||
|
||||
fun main() {
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
// Lambdas/ListIndicesMap.kt
|
||||
package lambdas
|
||||
import atomictest.eq
|
||||
|
||||
fun main() {
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
// Lambdas/Mapping.kt
|
||||
package lambdas
|
||||
import atomictest.eq
|
||||
|
||||
fun main() {
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
// Lambdas/OmittingParentheses.kt
|
||||
package lambdas
|
||||
import atomictest.eq
|
||||
|
||||
fun main() {
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
// Lambdas/TwoArgLambda.kt
|
||||
package lambdas
|
||||
import atomictest.eq
|
||||
|
||||
fun main() {
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
// Lambdas/Underscore.kt
|
||||
package lambdas
|
||||
import atomictest.eq
|
||||
|
||||
fun main() {
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
// Lambdas/ZeroArguments.kt
|
||||
package lambdas
|
||||
import atomictest.eq
|
||||
|
||||
fun main() {
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
// LocalFunctions/CustomLabel.kt
|
||||
package localfunctions
|
||||
|
||||
fun main() {
|
||||
val list = listOf(1, 2, 3, 4, 5)
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
// LocalFunctions/LabeledReturn.kt
|
||||
package localfunctions
|
||||
|
||||
fun main() {
|
||||
val list = listOf(1, 2, 3, 4, 5)
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
// LocalFunctions/LocalExtensions.kt
|
||||
package localfunctions
|
||||
import atomictest.eq
|
||||
|
||||
fun main() {
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
// LocalFunctions/LocalFunctionReference.kt
|
||||
package localfunctions
|
||||
import localfunctions.*
|
||||
import atomictest.eq
|
||||
|
||||
fun main() {
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
// LocalFunctions/LocalFunctions.kt
|
||||
package localfunctions
|
||||
|
||||
fun main() {
|
||||
val logMsg = StringBuilder()
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
// LocalFunctions/ReturnFromFun.kt
|
||||
package localfunctions
|
||||
|
||||
fun main() {
|
||||
val list = listOf(1, 2, 3, 4, 5)
|
||||
|
|
|
@ -7,18 +7,18 @@ fun first(): (Int) -> Int {
|
|||
return i + 1
|
||||
}
|
||||
func(1) eq 2
|
||||
return func // [1]
|
||||
return func
|
||||
}
|
||||
|
||||
fun second(): (String) -> String {
|
||||
val func2 = { s: String -> "$s!" }
|
||||
func2("abc") eq "abc!"
|
||||
return func2 // [1]
|
||||
return func2
|
||||
}
|
||||
|
||||
fun third(): () -> String {
|
||||
fun greet() = "Hi!"
|
||||
return ::greet // [1]
|
||||
return ::greet
|
||||
}
|
||||
|
||||
fun main() {
|
||||
|
@ -26,7 +26,7 @@ fun main() {
|
|||
val secondFun: (String) -> String = second()
|
||||
val thirdFun: () -> String = third()
|
||||
|
||||
firstFun(42) eq 43 // [2]
|
||||
secondFun("xyz") eq "xyz!" // [3]
|
||||
thirdFun() eq "Hi!" // [4]
|
||||
firstFun(42) eq 43
|
||||
secondFun("xyz") eq "xyz!"
|
||||
thirdFun() eq "Hi!"
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
## Local Functions (#1)
|
||||
|
||||
Demonstrate that you can put a local function inside another local function by
|
||||
writing a function `f()` which returns the result of its local function `g()`
|
||||
writing a function `f()` that returns the result of its local function `g()`
|
||||
which in turn returns the result of *it's* local function `h()`, which simply
|
||||
returns the value `47`.
|
|
@ -1,4 +1,5 @@
|
|||
// ManipulatingLists/Flatten.kt
|
||||
package manipulatinglists
|
||||
import atomictest.eq
|
||||
|
||||
fun main() {
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
// ManipulatingLists/FlattenAndFlatMap.kt
|
||||
package manipulatinglists
|
||||
import atomictest.eq
|
||||
|
||||
fun main() {
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
// ManipulatingLists/Zipper.kt
|
||||
package manipulatinglists
|
||||
import atomictest.eq
|
||||
|
||||
fun main() {
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
// ManipulatingLists/ZippingWithNext.kt
|
||||
package manipulatinglists
|
||||
import atomictest.eq
|
||||
|
||||
fun main() {
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
The starter code includes a `data` class called `Pet` containing a `var String`
|
||||
property `name` and an `enum` property `habitat`. The `Habitat` enumeration can
|
||||
be `LAND`, `WATER` or `AMPHIBIOUS`, and it also contains a member function
|
||||
`livesIn(pet: Pet)` which tests to see whether a `pet` lives in a particular
|
||||
`livesIn(pet: Pet)` that tests to see whether `pet` lives in a particular
|
||||
`Habitat`.
|
||||
|
||||
The `main()` starter code creates a `List<Pet>`. Using `filter()` together with
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
// OperationsOnCollections/ByOperations.kt
|
||||
package operationsoncollections
|
||||
import atomictest.eq
|
||||
|
||||
data class Product(
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
// OperationsOnCollections/CreatingLists.kt
|
||||
package operationsoncollections
|
||||
import atomictest.eq
|
||||
|
||||
fun main() {
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
// OperationsOnCollections/FilterNotNull.kt
|
||||
package operationsoncollections
|
||||
import atomictest.eq
|
||||
|
||||
fun main() {
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
// OperationsOnCollections/ListInit.kt
|
||||
package operationsoncollections
|
||||
import atomictest.eq
|
||||
|
||||
fun main() {
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
// OperationsOnCollections/OperationsOnSets.kt
|
||||
package operationsoncollections
|
||||
import atomictest.eq
|
||||
|
||||
fun main() {
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
// OperationsOnCollections/PairOfLists.kt
|
||||
package operationsoncollections
|
||||
import atomictest.eq
|
||||
|
||||
fun createPair() = Pair(1, "one")
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
// OperationsOnCollections/Partition.kt
|
||||
package operationsoncollections
|
||||
import atomictest.eq
|
||||
|
||||
fun main() {
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
// OperationsOnCollections/Predicates.kt
|
||||
package operationsoncollections
|
||||
import atomictest.eq
|
||||
|
||||
fun main() {
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
// OperationsOnCollections/TakeOrDrop.kt
|
||||
package operationsoncollections
|
||||
import atomictest.eq
|
||||
|
||||
fun main() {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
## Operations on Collections (#2)
|
||||
|
||||
The starter code contains a skeleton for a lambda named `operation` which is
|
||||
The starter code contains a skeleton for a lambda named `operation` that is
|
||||
used as a predicate in several function calls on a `List`. Implement
|
||||
`operation` so the function calls produce the specified results.
|
|
@ -1,6 +1,6 @@
|
|||
## Recursion (#1)
|
||||
|
||||
Write a tail recursive function called `simulation()` which takes a `String`
|
||||
Write a tail recursive function called `simulation()` that takes a `String`
|
||||
called `group` and an `Int` called `level`. It displays `"Simulation: $group
|
||||
Reality: level"`, then calls itself with `level - 1` as long as `level` is
|
||||
greater than zero.
|
|
@ -1,5 +1,5 @@
|
|||
// Sequences/DefineTakeIf.kt
|
||||
package definetakeif
|
||||
package sequences
|
||||
import atomictest.eq
|
||||
|
||||
fun <T> T.takeIf(
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
// Sequences/EagerEvaluation.kt
|
||||
package sequences
|
||||
import atomictest.eq
|
||||
|
||||
fun main() {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// Sequences/EagerVsLazyEvaluation.kt
|
||||
package creatingsequences
|
||||
package sequences
|
||||
import atomictest.*
|
||||
|
||||
fun Int.isEven(): Boolean {
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
// Sequences/InputLines1.kt
|
||||
package sequences
|
||||
|
||||
fun main() {
|
||||
val lines = generateSequence {
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
// Sequences/InputLines2.kt
|
||||
package sequences
|
||||
|
||||
fun main() {
|
||||
val lines = generateSequence {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// Sequences/NoComputationYet.kt
|
||||
package creatingsequences
|
||||
package sequences
|
||||
|
||||
fun main() {
|
||||
val list = listOf(1, 2, 3, 4)
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
// Sequences/NumberSequence1.kt
|
||||
package sequences
|
||||
import atomictest.eq
|
||||
|
||||
fun main() {
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
// Sequences/NumberSequence2.kt
|
||||
package sequences
|
||||
import atomictest.eq
|
||||
|
||||
fun main() {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// Sequences/TerminalOperations.kt
|
||||
package creatingsequences
|
||||
package sequences
|
||||
import atomictest.*
|
||||
|
||||
fun main() {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
## Sequences (#3)
|
||||
|
||||
Implement the `School` extension function `averageInstructorRating()` which
|
||||
Implement the `School` extension function `averageInstructorRating()` that
|
||||
takes `Instructor` as a parameter and calculates the average rating that the
|
||||
instructor was given by all the students that attended his or her classes. If a
|
||||
student attended several lessons by that instructor, the ratings for individual
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
// ImportanceOfLambdas/Closures.kt
|
||||
package importanceoflambdas
|
||||
import atomictest.eq
|
||||
|
||||
fun main() {
|
||||
val list = listOf(1, 5, 7, 10)
|
||||
val divider = 5
|
||||
|
||||
list.filter { it % divider == 0 } eq
|
||||
listOf(5, 10)
|
||||
}
|
|
@ -1,4 +1,5 @@
|
|||
// ImportanceOfLambdas/Closures2.kt
|
||||
package importanceoflambdas
|
||||
import atomictest.eq
|
||||
|
||||
fun main() {
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
// ImportanceOfLambdas/Filter.kt
|
||||
package importanceoflambdas
|
||||
import atomictest.eq
|
||||
|
||||
fun main() {
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
// ImportanceOfLambdas/FilterEven.kt
|
||||
package importanceoflambdas
|
||||
import atomictest.eq
|
||||
|
||||
fun filterEven(nums: List<Int>): List<Int> {
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
// ImportanceOfLambdas/FunctionClosure.kt
|
||||
package importanceoflambdas
|
||||
import atomictest.eq
|
||||
|
||||
var x = 100
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
// ImportanceOfLambdas/GreaterThan2.kt
|
||||
package importanceoflambdas
|
||||
import atomictest.eq
|
||||
|
||||
fun greaterThan2(nums: List<Int>): List<Int> {
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
// ImportanceOfLambdas/StoringLambda.kt
|
||||
package importanceoflambdas
|
||||
import atomictest.eq
|
||||
|
||||
fun main() {
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
// ImportanceOfLambdas/Sum.kt
|
||||
package importanceoflambdas
|
||||
import atomictest.eq
|
||||
|
||||
fun main() {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
## The Importance of Lambdas (#1)
|
||||
|
||||
The starter code defines a `Person` class. Create an extension function to
|
||||
`List<Person>` called `getNamesOfAdults()` which returns the names of all
|
||||
`List<Person>` called `getNamesOfAdults()` that returns the names of all
|
||||
people older than 17.
|
|
@ -1,8 +0,0 @@
|
|||
// Constructors/Bear.kt
|
||||
package complexconstructors
|
||||
|
||||
class Bear
|
||||
|
||||
fun main() {
|
||||
val bear = Bear()
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
// Constructors/Wombat.kt
|
||||
|
||||
class Wombat
|
||||
|
||||
fun main() {
|
||||
val wombat = Wombat()
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
type: theory
|
||||
files:
|
||||
- name: src/Bear.kt
|
||||
- name: src/Wombat.kt
|
||||
visible: true
|
||||
- name: src/Arg.kt
|
||||
visible: true
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
// Exceptions/IntroducingCapture.kt
|
||||
package exceptions
|
||||
import atomictest.*
|
||||
|
||||
fun main() {
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
// Exceptions/IntroducingNull.kt
|
||||
package exceptions
|
||||
import atomictest.eq
|
||||
|
||||
fun main() {
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
// Exceptions/ToIntException.kt
|
||||
package exceptions
|
||||
|
||||
fun erroneousCode() {
|
||||
// Uncomment this line to get an exception:
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
// Lists/ListUsefulFunction.kt
|
||||
package lists
|
||||
import atomictest.eq
|
||||
|
||||
fun main() {
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
// Lists/Lists.kt
|
||||
package lists
|
||||
import atomictest.eq
|
||||
|
||||
fun main() {
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
// Lists/MultipleListRefs.kt
|
||||
package lists
|
||||
import atomictest.eq
|
||||
|
||||
fun main() {
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
// Lists/MutListIsList.kt
|
||||
package lists
|
||||
import atomictest.eq
|
||||
|
||||
fun getList(): List<Int> {
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
// Lists/MutableList.kt
|
||||
package lists
|
||||
import atomictest.eq
|
||||
|
||||
fun main() {
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
// Lists/OutOfBounds.kt
|
||||
package lists
|
||||
import atomictest.*
|
||||
|
||||
fun main() {
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
// Lists/ParameterizedReturn.kt
|
||||
package lists
|
||||
import atomictest.eq
|
||||
|
||||
// Return type is inferred:
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
// Lists/ParameterizedTypes.kt
|
||||
package lists
|
||||
import atomictest.eq
|
||||
|
||||
fun main() {
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
// Maps/ContactMap.kt
|
||||
package maps
|
||||
import atomictest.eq
|
||||
|
||||
class Contact(
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
// Maps/GetValue.kt
|
||||
package maps
|
||||
import atomictest.*
|
||||
|
||||
fun main() {
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
// Maps/Maps.kt
|
||||
package maps
|
||||
import atomictest.eq
|
||||
|
||||
fun main() {
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
// Maps/MutableMaps.kt
|
||||
package maps
|
||||
import atomictest.eq
|
||||
|
||||
fun main() {
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
// Maps/ReadOnlyMaps.kt
|
||||
package maps
|
||||
import atomictest.eq
|
||||
|
||||
fun main() {
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
## Packages (#3)
|
||||
|
||||
The starter code contains a `package` named `pythagorean`. Add a class
|
||||
`EquilateralTriangle` which takes a constructor parameter `side: Double`.
|
||||
Define a member function `area()` which calculates the triangle area using the
|
||||
`EquilateralTriangle` that takes a constructor parameter `side: Double`.
|
||||
Define a member function `area()` that calculates the triangle area using the
|
||||
formula `sqrt(3.0) / 4 * side * side`.
|
||||
|
||||
In the starter code, uncomment the `main()` function code inside
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue