Skip to content

Commit cab14f4

Browse files
authored
Fix typos and documentation in Part 9-2
1 parent dd2fe34 commit cab14f4

File tree

1 file changed

+4
-29
lines changed

1 file changed

+4
-29
lines changed

data/part-9/2-interfaces.md

Lines changed: 4 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -912,36 +912,11 @@ public class Factory {
912912
}
913913
}
914914
}
915+
```
915916

916917

917-
<!-- Tehdasta on mahdollista käyttää tuntematta tarkalleen mitä erityyppisiä Talletettava-rajapinnan luokkia on olemassa. Seuraavassa luokka Pakkaaja, jolta voi pyytää laatikollisen esineitä. Pakkaaja tuntee tehtaan, jota se pyytää luomaan esineet: -->
918-
919918
The Factory can be used without exactly knowing what different kind of Packable classes exist. In the next example there is a class Packer that gives a box of things. A packer defines a factory which is used to create the things:
920919

921-
<!--
922-
// ```java
923-
// public class Pakkaaja {
924-
// private Tehdas tehdas;
925-
926-
// public Pakkaaja() {
927-
// this.tehdas = new Tehdas();
928-
// }
929-
930-
// public Laatikko annaLaatikollinen() {
931-
// Laatikko laatikko = new Laatikko(100);
932-
933-
// int i = 0;
934-
// while (i < 10) {
935-
// Talletettava uusiTavara = tehdas.valmistaUusi();
936-
// laatikko.lisaa(uusiTavara);
937-
938-
// i = i + 1;
939-
// }
940-
941-
// return laatikko;
942-
// }
943-
// }
944-
// ``` -->
945920

946921
```java
947922
public class Packer {
@@ -1140,7 +1115,7 @@ names.add("First");
11401115
names.add("Second");
11411116
names.add("Third");
11421117

1143-
System.out.println(palautaKoko(names));
1118+
System.out.println(returnSize(names));
11441119
```
11451120

11461121
<sample-output>
@@ -1213,7 +1188,7 @@ hai: yes
12131188

12141189
<!--Metodi `keySet` palauttaa `Set`-rajapinnan toteuttavan joukon alkioita. `Set`-rajapinnan toteuttavan joukon voi käydä läpi `for-each`-lauseella. Hajautustaulusta saa talletetut arvot metodin `values`-avulla. Metodi `values` palauttaa `Collection` rajapinnan toteuttavan joukon alkioita. Tutustutaan vielä pikaisesti Set- ja Collection-rajapintoihin. -->
12151190

1216-
The `keySet` method returns a set of elements that implement the `Set` interface. You can use a for-each statement to go through a set that implements the `Set` interface. The hash values can be obtained from the hash table using the `values` method. The `values` method returns a set of elements that implement the `Collection` interface. Let's take a quidk look at the `Set` and `Collection` interfaces.
1191+
The `keySet` method returns a set of elements that implement the `Set` interface. You can use a for-each statement to go through a set that implements the `Set` interface. The hash values can be obtained from the hash table using the `values` method. The `values` method returns a set of elements that implement the `Collection` interface. Let's take a quick look at the `Set` and `Collection` interfaces.
12171192
12181193
<programming-exercise name='Map as a method parameter' tmcname='part09-Part09_08.MapAsAMethodParameter'>
12191194
@@ -1510,7 +1485,7 @@ Esimerkki varaston käytöstä: -->
15101485
Save the stock balance of products in a variable with the `Map<String, Integer>` type, in the same way the prices were stored. Supplement the warehouse with the following methods:
15111486

15121487
- `public int stock(String product)` returns the current remaining stock of the product in the warehouse. If the product hasn't been added to the warehouse, the method must return 0.
1513-
- `public boolean take(String product)` reduces the stock ramaining for the product it received as a parameter by one, and returns true if there was stock remaining. If the product was not available in the warehouse the method returns false. A products stock can't go below zero.
1488+
- `public boolean take(String product)` reduces the stock remaining for the product it received as a parameter by one, and returns true if there was stock remaining. If the product was not available in the warehouse the method returns false. A products stock can't go below zero.
15141489

15151490
An example of the warehouse in use:
15161491
<!-- ```java

0 commit comments

Comments
 (0)