Skip to content

Commit c1dc1e0

Browse files
Merge branch 'master' into patch-3
2 parents 79ad1f6 + 9dcf387 commit c1dc1e0

32 files changed

+145
-140
lines changed

course-settings.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,6 @@ const courseSettings = {
2525
title: "Frequently asked questions",
2626
path: "/faq",
2727
},
28-
{
29-
title:"Exam 29.8",
30-
path: "/exam"
31-
},
3228
{ separator: true, title: "Java Programming I" },
3329
],
3430
sidebarFuturePages: [

data/exam.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
path: "/exam"
33
title: "Exam 05.09"
4-
hidden: false
4+
hidden: true
55
information_page: true
66
---
77

data/part-1/1-starting-programming.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ Modern programming is practically always done in an IDE (integrated development
2424

2525
<!-- Käytämme tällä kurssilla [NetBeans](https://netbeans.apache.org)-nimistä ohjelmointiympäristöä sekä siihen liitettävää Test My Code -liitännäistä. -->
2626

27-
The IDE we use on this course is called [NetBeans](https://netbeans.apache.org), and we use it with Test My Code plugin.
27+
The IDE we use on this course is called [NetBeans](https://netbeans.apache.org), and we use it with the Test My Code plugin.
2828

2929
<!-- Tarvitset kurssin aloittamiseen (1) käyttäjätunnuksen kurssilla käytettyyn TMC-järjestelmään, (2) Javan (Java JDK), ja (3) NetBeans with TMC -ohjelmointiympäristön (jatkossa TMC). Näiden asentaminen onnistuu seuraavia ohjeita noudattamalla. -->
3030

data/part-1/3-reading-input.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ Once upon a time...
361361
## Input String as a Part of Output
362362

363363
<!-- Huomasimme ohjelmointitehtävässä "Hei Ada Lovelace!", että merkkijonoliteraaleja ja merkkijonomuuttujia voidaan yhdistää `+`-merkillä. Alla oleva esimerkki näyttää ohjelman, missä käyttäjältä luetaan merkkijono, joka tulostetaan merkkijonoliteraaliin yhdistettynä. -->
364-
We noticed in the "Hi Ava Lovelace!" exercise that string literals and string variables can be joined using the `+` -operator. The example below demonstrates a program that takes user input and prints it concatenated with a string literal.
364+
We noticed in the "Hi Ada Lovelace!" exercise that string literals and string variables can be joined using the `+` operator. The example below demonstrates a program that takes user input and prints it concatenated with a string literal.
365365

366366
```java
367367
import java.util.Scanner;
@@ -575,7 +575,7 @@ public class Program {
575575

576576
System.out.println("Last string you wrote was " + third + ", which ");
577577
System.out.println("was preceded by " + second+ ".");
578-
System.out.println("The first string was" + first + ".");
578+
System.out.println("The first string was " + first + ".");
579579

580580
System.out.println("All together: " + first + second + third);
581581
}

data/part-1/4-variables.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ Open the questionnaire by following the link
4949

5050
<!-- Tutustuimme syötteen lukemisen yhteydessä jo pikaisesti merkkijonomuuttujiin. Tutustutaan seuraavaksi muihin usein käytettyihin Javan muuttujatyyppeihin. -->
5151

52-
We've already familiarized ourselvese with strings to a degree while dealing with user inputs. Let's turn our attention to learning about other variable *types* commonly used in Java.
52+
We've already familiarized ourselves with strings to a degree while dealing with user inputs. Let's turn our attention to learning about other variable *types* commonly used in Java.
5353

5454
<!-- Muuttujaa kannattaa ajatella lokerona, johon voi tallettaa annetun tyyppistä tietoa. Tyyppejä ovat esimerkiksi teksti eli merkkijono (`String`), kokonaisluku (`int`), liukuluku (`double`) eli desimaaliluku, ja totuusarvo (`boolean`). Muuttujaan asetetaan arvo yhtäsuuruusmerkillä (`=`). -->
5555

data/part-1/6-conditional-statements.md

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -476,8 +476,10 @@ Greater number is: 8
476476

477477
<sample-output>
478478

479-
Give the first number; **5**
480-
Give the second number: **5**
479+
Give the first number:
480+
**5**
481+
Give the second number:
482+
**5**
481483
The numbers are equal!
482484

483485
</sample-output>
@@ -1167,13 +1169,13 @@ int number = 7;
11671169
if (!(number > 4)) {
11681170
System.out.println("The number is not greater than 4.");
11691171
} else {
1170-
System.out.println("The number is greater than or equal to 4.")
1172+
System.out.println("The number is greater than 4.")
11711173
}
11721174
```
11731175

11741176
<sample-output>
11751177

1176-
The number is greater than or equal to 4.
1178+
The number is greater than 4.
11771179

11781180
</sample-output>
11791181

@@ -1524,17 +1526,17 @@ if (number % 4 != 0) {
15241526

15251527
When a gift is given by a close relative or a family member, the amount of gift tax is determined by the following table (source [vero.fi](https://www.vero.fi/en/individuals/property/gifts/gift-tax-calculator/#gifttaxtables)):
15261528

1527-
| Value of gift | Tax at the lower limit | Tax rate(%) for exceeding part |
1528-
| -------------------- | ---------------------- | ------------------------------ |
1529-
| 5 000 -- 25 000 | 100 | 8 |
1530-
| 25 000 -- 55 000 |  1 700 | 10 |
1531-
| 55 000 -- 200 000 | 4 700 | 12 |
1532-
| 200 000 -- 1 000 000 | 22 100 | 15 |
1533-
| 1 000 000 -- | 142 100 | 17 |
1529+
| Value of gift | Tax at the lower limit | Tax rate(%) for exceeding part |
1530+
| -------------------- | ---------------------- | ------------------------------ |
1531+
| 5 000 -- 25 000 | 100 | 8 |
1532+
| 25 000 -- 55 000 | 1 700 | 10 |
1533+
| 55 000 -- 200 000 | 4 700 | 12 |
1534+
| 200 000 -- 1 000 000 | 22 100 | 15 |
1535+
| 1 000 000 -- | 142 100 | 17 |
15341536

15351537
<!-- Esimerkiksi 6000 euron lahjasta tulee maksaa veroa 180 euroa (100 + (6000-5000) * 0.08), ja 75000 euron lahjasta tulee maksaa veroa 7100 euroa (4700 + (75000-55000) * 0.12). -->
1536-
1537-
For example 6000€ gift implies 180€ of gift tax (100 + (6000-5000)_0.08), and 75000€ gift implies 7100€ of gift tax (4700 + (75000-55000) _ 0.12).
1538+
<!-- The formula used to calculate the gift tax is: (Tax at the lower limit + (Value of gift (€) - minimum value of gift (€)) * (Tax Rate (%) / 100) -->
1539+
For example 6000€ gift implies 180€ of gift tax (100 + (6000-5000) * 0.08), and 75000€ gift implies 7100€ of gift tax (4700 + (75000-55000) * 0.12).
15381540

15391541
<!-- Tee ohjelma, joka laskee lahjaveron lähimmiltä sukulaisilta annetulle lahjalle. Alla on muutama esimerkki ohjelman toiminnasta. -->
15401542

data/part-10/1-handling-collections-as-streams.md

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ double average = inputs.stream()
143143
<!-- Keskiarvon laskeminen onnistuu virrasta, jolle on kutsuttu `mapToInt`-metodia. Kokonaislukuja sisältävällä virralla on metodi `average()`, joka palauttaa <a href="https://docs.oracle.com/javase/8/docs/api/java/util/OptionalDouble.html" target="_blank" norel>OptionalDouble</a>-tyyppisen olion. Oliolla on metodi `getAsDouble()`, joka palauttaa listan arvojen keskiarvon `double`-tyyppisenä muuttujana.
144144
145145
Lyhyt yhteenveto tähän mennessä tutuiksi tulleista virtaan liittyvistä metodeista. -->
146-
Calculating the average is possible from a stream that has the `mapToInt` method called on it. A stream of integers has an `average` method that returns an <a href="https://docs.oracle.com/javase/8/docs/api/java/util/OptionalDouble.html" target="_blank" norel>OptionalDouble</a>-type object. The object has `getAsDouble()` method that returns the average of the list values as a type `double` varaible.
146+
Calculating the average is possible from a stream that has the `mapToInt` method called on it. A stream of integers has an `average` method that returns an <a href="https://docs.oracle.com/javase/8/docs/api/java/util/OptionalDouble.html" target="_blank" norel>OptionalDouble</a>-type object. The object has `getAsDouble()` method that returns the average of the list values as a `double` type variable.
147147

148148
A brief summary of the stream methods we've encountered so far.
149149

@@ -216,7 +216,7 @@ A brief summary of the stream methods we've encountered so far.
216216

217217
<tr>
218218
<td>
219-
Stream formation: `stream()`
219+
Stream formation: <code>stream()</code>
220220
</td>
221221
<td>
222222
The method is called on collection that implements the Collection interface, such as an ArrayList Object. Something is done on the created stream.
@@ -225,7 +225,7 @@ A brief summary of the stream methods we've encountered so far.
225225

226226
<tr>
227227
<td>
228-
Converting a stream into an integer stream: `mapToInt(value -> another)`
228+
Converting a stream into an integer stream: <code>mapToInt(value -> another)</code>
229229
</td>
230230
<td>
231231
The stream transforms into one containing integers.
@@ -237,30 +237,30 @@ A brief summary of the stream methods we've encountered so far.
237237
<tr>
238238
<td>
239239
Filtering values:
240-
`filter(value -> filter condition)`
240+
<code>filter(value -> filter condition)</code>
241241
</td>
242242
<td>
243243
The elements that do not satisfy the filter condition are removed from the string.
244244
On the right side of the arrow is a statement that returns a boolean.
245-
If the boolean is `true`, the element is accepted into the stream. If the boolean evaluates to false, the value is not accepted into the stream. Something is done with the filtered values.
245+
If the boolean is <code>true</code>, the element is accepted into the stream. If the boolean evaluates to false, the value is not accepted into the stream. Something is done with the filtered values.
246246
</td>
247247
</tr>
248248

249249
<tr>
250250
<td>
251-
Calculating the average: `average()`
251+
Calculating the average: <code>average()</code>
252252
</td>
253253
<td>
254-
Returns a OptionalDouble-type object that has a method `getAsDouble()` that returns a value of type `double`. Calling the method `average()` works on streams that contain integers - they can be created with the `mapToInt` method.
254+
Returns a OptionalDouble-type object that has a method <code>getAsDouble()</code> that returns a value of type <code>double</code>. Calling the method <code>average()</code> works on streams that contain integers - they can be created with the <code>mapToInt</code> method.
255255
</td>
256256
</tr>
257257

258258
<tr>
259259
<td>
260-
Counting the number of elements in a stream: `count()`
260+
Counting the number of elements in a stream: <code>count()</code>
261261
</td>
262262
<td>
263-
Returns the number of elements in a stream as a `long`-type value.
263+
Returns the number of elements in a stream as a <code>long</code>-type value.
264264
</td>
265265
</tr>
266266

@@ -353,7 +353,7 @@ Average of the positive numbers: 1.5
353353
Miksi funktiot kirjoitetaan muodossa `luku -> luku > 5`?
354354
355355
Kyseinen kirjoitusmuoto, *lambda-lauseke*, on Javan tarjoama lyhenne ns. anonyymeille metodeille, joilla ei ole "omistajaa" eli ne eivät ole osa luokkaa tai rajapintaa. Funktio sisältää sekä parametrien määrittelyn että funktion rungon. Saman funktion voi kirjoittaa useammalla eri tavalla, kts. alla. -->
356-
Stream values ​​are handled by methods related to streams. Methods that handle values ​​get a function as a parameter that determines what is done with each element. What the function does is specific to the method in question. For instance, the `filter` method used for filtering elements is provided a function which returns the a boolean `true` or `false`, depending on whether to keep the value in the stream or not. The `mapToInt` method used for transformation is, on the other hand, provided a function which converts the value to an integer, and so on.
356+
Stream values ​​are handled by methods related to streams. Methods that handle values ​​get a function as a parameter that determines what is done with each element. What the function does is specific to the method in question. For instance, the `filter` method used for filtering elements is provided a function which returns a boolean `true` or `false`, depending on whether to keep the value in the stream or not. The `mapToInt` method used for transformation is, on the other hand, provided a function which converts the value to an integer, and so on.
357357

358358
Why are the functions written in the form `value -> value > 5`?
359359

@@ -438,7 +438,7 @@ The function can also be passed directly as a parameter. The syntax found below
438438
<!-- Virran arvoja käsittelevät funktiot eivät voi muuttaa funktion ulkopuolisten muuttujien arvoja. Kyse on käytännössä staattisten metodien käyttäytymisestä -- metodia kutsuttaessa metodin ulkopuolisiin muuttujiin ei pääse käsiksi. Funktioiden tilanteessa funktion ulkopuolisten muuttujien arvoja voi lukea olettaen, että luettavien muuttujien arvot eivät muutu lainkaan ohjelmassa.
439439
440440
Alla oleva ohjelma demonstroi tilannetta, missä funktiossa yritetään hyödyntää funktion ulkopuolista muuttujaa. Tämä ei toimi. -->
441-
Functions thats handle stream elements ​​cannot change values ​​of variables outside of the function. This has to do with how static methods behave - during a method call, there is no access to any variables outside of the method. With functions, the values ​​of variables outside the function can be read, assuming that those values of those variables do not change in the program.
441+
Functions that handle stream elements ​​cannot change values ​​of variables outside of the function. This has to do with how static methods behave - during a method call, there is no access to any variables outside of the method. With functions, the values ​​of variables outside the function can be read, assuming that those values of those variables do not change in the program.
442442

443443
The program below demonstrates the situation in which a function attempts to make use of a variable outside the function. It doesn't work.
444444

@@ -564,7 +564,7 @@ Implement the method using stream! For collecting the numbers try the command `C
564564

565565
Metodi `count` kertoo virran alkioiden lukumäärän `long`-tyyppisenä muuttujana. -->
566566

567-
Let's take a look at four terminal operations: the `count` method for counting the number of values on a list ​​using the, the `forEach` method for going a through list values, the `collect` method for gathering the list values ​​into a data structure, and the `reduce` method for combining the list items.
567+
Let's take a look at four terminal operations: the `count` method for counting the number of values on a list, the `forEach` method for going a through list values, the `collect` method for gathering the list values ​​into a data structure, and the `reduce` method for combining the list items.
568568

569569
The `count` method informs us of the number of values in the stream as a `long`-type variable.
570570

@@ -601,7 +601,7 @@ Values: 5
601601
</sample-output>
602602

603603
<!-- Metodi `forEach` kertoo mitä kullekin listan arvolle tulee tehdä ja samalla päättää virran käsittelyn. Alla olevassa esimerkissä luodaan ensin numeroita sisältävä lista, jonka jälkeen tulostetaan vain kahdella jaolliset luvut. -->
604-
The `forEach` method defines what is done to each list value and terminated the stream processing. In the example below, we first create a list of numbers, after which we only print the numbers that are divisible by two.
604+
The `forEach` method defines what is done to each list value and terminates the stream processing. In the example below, we first create a list of numbers, after which we only print the numbers that are divisible by two.
605605

606606

607607
<!-- ```java
@@ -668,7 +668,7 @@ ArrayList<Integer> positives = values.stream()
668668
.filter(value -> value > 0)
669669
.collect(Collectors.toCollection(ArrayList::new));
670670

671-
positiiviset.stream()
671+
positives.stream()
672672
.forEach(value -> System.out.println(value));
673673
```
674674

@@ -916,7 +916,7 @@ System.out.println("Lukumäärä: " + lkm);
916916
// ArrayList<Person> persons = new ArrayList<>();
917917
918918
long count = persons.stream()
919-
.filter(person -> persons.getFirstName().startsWith("A"))
919+
.filter(person -> person.getFirstName().startsWith("A"))
920920
.count();
921921
System.out.println("Count: " + count);
922922
```
@@ -1288,7 +1288,7 @@ The exercise template includes the probably familiar project "Cargo hold". Howev
12881288
<!-- Virta on myös erittäin näppärä tiedostojen käsittelyssä. Tiedoston lukeminen virtamuotoisena tapahtuu Javan valmiin <a href="https://docs.oracle.com/javase/8/docs/api/java/nio/file/Files.html" target="_blank" rel="noopener">Files</a>-luokan avulla. Files-luokan metodin `lines` avulla tiedostosta voidaan luoda syötevirta, jonka avulla tiedoston rivit voidaan käsitellä yksi kerrallaan. Metodi `lines` saa patametrikseen polun, joka luodaan luokan <a href="https://docs.oracle.com/javase/8/docs/api/java/nio/file/Paths.html" target="_blank" rel="noopener">Paths</a> tarjoamalla metodilla `get`, jolle annetaan parametrina tiedostopolkua kuvaava merkkijono.
12891289

12901290
Alla olevassa esimerkissä luetaan tiedoston "tiedosto.txt" kaikki rivit ja lisätään ne listaan. -->
1291-
<p>Streams are also very handy in handling files. The file is read in stream form using Java's ready-made <a href="https://docs.oracle.com/javase/8/docs/api/java/nio/file/Files.html" target="_blank" rel="noopener">Files</a> class. The `lines` method in the files class allows you to create an input stream from a file, allowing you to process the rows one by one. The `lines` method gets a path as its parameter, which is created using the `get` method in the <a href="https://docs.oracle.com/javase/8/docs/api/java/nio/file/Paths.html" target="_blank" rel="noopener">Paths</a> class. The `get` method is provided a string describing the file path.</p>
1291+
<p>Streams are also very handy in handling files. The file is read in stream form using Java's ready-made <a href="https://docs.oracle.com/javase/8/docs/api/java/nio/file/Files.html" target="_blank" rel="noopener">Files</a> class. The <code>lines</code> method in the files class allows you to create an input stream from a file, allowing you to process the rows one by one. The <code>lines</code> method gets a path as its parameter, which is created using the <code>get</code> method in the <a href="https://docs.oracle.com/javase/8/docs/api/java/nio/file/Paths.html" target="_blank" rel="noopener">Paths</a> class. The <code>get</code> method is provided a string describing the file path.</p>
12921292
12931293
The example below reads all the lines in "file.txt" and adds them to the list.
12941294

0 commit comments

Comments
 (0)