开源软件名称(OpenSource Name):pysaumont/fpinkotlin开源软件地址(OpenSource Url):https://github.com/pysaumont/fpinkotlin开源编程语言(OpenSource Language):Kotlin 100.0%开源软件介绍(OpenSource Introduction):This repository contains code, exercises and solutions from the book "The Joy of Kotlin". How to use the projectThe code is available as a Gradle project that may be used by:
Downloading the projectThere are two ways to download this project.You may:
Importing into IntelliJIntelliJ offers the best support for Kotlin development, plus full Gradle integration.If you don’t have IntelliJ, just download the Community version from the JetBrains site.This free version has all you need for using the examples and solving the exercises in the book. To import the project into IntelliJ:
Running a testEach exercise as has a corresponding test that will fail until you implement a valid solution.To test you solution, simply run the corresponding test:
Using Gradle to run the testIf you do not want to use IntelliJ, you can use any text editor to create an implementation for an exercise.Then you can run the corresponding test using Gradle from the command line.If you chose this solution, I suppose you will already have Gradle setup.If not, just download the current version from the Gradle site and install it. Running a single testThe command to use to run all tests with Gradle is: gradle test However, this is not what you’ll want since it would take to much time and it would run tests for exercises you have not solved yet, and these tests would fail. Let’s say you just solved gradle :fpinkotlin-advancedlisthandling-exercises:test --tests com.fpinkotlin.advancedlisthandling.exercise01.ListTest If the test fails, you will get something like: com.fpinkotlin.advancedlisthandling.exercise01.ListTest > ListTest.length FAILED java.lang.AssertionError 1 test completed, 1 failed :fpinkotlin-advancedlisthandling-exercises:test FAILED FAILURE: Build failed with an exception. * What went wrong: Execution failed for task ':fpinkotlin-advancedlisthandling-exercises:test'. > There were failing tests.See the report at: file://<PATH_TO_PROJECT>/fpinkotlin-parent/fpinkotlin-advancedlisthandling-exercises/build/reports/tests/index.html Fix your solution and try again. On the other hand, if the test succeeds, you get something like: ... :fpinkotlin-advancedlisthandling-exercises:test BUILD SUCCESSFUL Total time: 15.67 secs If you think some information is missing, I will agree.You can use the gradle :fpinkotlin-advancedlisthandling-exercises:test --info --tests com.fpinkotlin.advancedlisthandling.exercise01.ListTest ... Successfully started process 'Gradle Test Executor 1' Gradle Test Executor 1 started executing tests. Gradle Test Executor 1 finished executing tests. Finished generating test XML results (0.029 secs) into: /media/KINGSTON2/fpinkotlin/fpinkotlin/fpinkotlin-parent/fpinkotlin-advancedlisthandling-exercises/build/test-results Generating HTML test report... Finished generating test html results (0.024 secs) into: /media/KINGSTON2/fpinkotlin/fpinkotlin/fpinkotlin-parent/fpinkotlin-advancedlisthandling-exercises/build/reports/tests :fpinkotlin-advancedlisthandling-exercises:test (Thread[main,5,main]) completed. Took 3.192 secs. BUILD SUCCESSFUL Total time: 16.222 secs Here is the report for a failed test: You may click on the test name to get detailed about what happened: Once the problem is fixed, the test succeeds and you get the following report: Doing the exercisesFor each chapter, you will find two modules called Note that code is often duplicated from one exercise to the another, so you should not look at the code for exercise 2 before doing exercise 1, since exercise 2 will often contain the solution to exercise one. Looking at solutionsIf you don’t find the correct solution to an exercise, you can look at the corresponding
Module namesCode modules are generally named after the chapter titles, and not the chapter numbers, which sometimes make them difficult to find.Here is the list of the modules:
Code example fro appendix A & BThe code examples for appendix A & B are to be found in the kotlingradle repository |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论