Skip to content

Change "lopeta" to "quit" in English version + others #180

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jul 15, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion data/part-7/3-larger-exercises.md
Original file line number Diff line number Diff line change
Expand Up @@ -737,7 +737,7 @@ Crow (Corvus Corvus): 0 observations
? **One**
Bird? **Hawk**
Hawk (Dorkus Dorkus): 2 observations
? **Lopeta**
? **Quit**

</sample-output>

Expand Down
6 changes: 3 additions & 3 deletions data/part-8/2-hash-map.md
Original file line number Diff line number Diff line change
Expand Up @@ -1016,7 +1016,7 @@ This way, however, we lose the speed advantage that comes with the hash map. The
<programming-exercise name='Print me my hash map' tmcname='part08-Part08_08.PrintMeMyHashmap'>

<!-- Tehtäväpohjassa tulee luokka `Ohjelma`. Luo luokkaan seuraavat kolme luokkametodia: -->
Exercise template contains a class `Program`. Implement the following class methods in the clas:
Exercise template contains a class `Program`. Implement the following class methods in the class:

<!-- - `public static void printKeys(HashMap<String, String> hajautustaulu)`, joka tulostaa parametrina annetun hajautustaulun avaimet. -->

Expand Down Expand Up @@ -1117,7 +1117,7 @@ In the class `Program` implement the following class methods:
the toString method of the Book objects.

<!-- - `public static void tulostaArvoJosNimessa(HashMap<String, Book> hajautustaulu, String merkkijono)`, joka tulostaa parametrina annetun hajautustaulun arvoista ne, joiden nimessä on parametrina annettu merkkijono. Nimen saa selville kirjan metodilla `getNimi`. -->
`public static void printValueIfNameContains(HashMap<String,Book> hashmap, String text)`, which prints only the Books in the given hashmap whichs name contains the given string. You can find out the name of a Book with the method `getName`.
- `public static void printValueIfNameContains(HashMap<String,Book> hashmap, String text)`, which prints only the Books in the given hashmap which name contains the given string. You can find out the name of a Book with the method `getName`.

<!-- Esimerkki luokkametodien käytöstä: -->
An example of using the class methods:
Expand Down Expand Up @@ -1162,7 +1162,7 @@ NB! The order of the output may vary. The implementation of a hashmap does not g

<!-- Hajautustaulu olettaa, että siihen lisätään viittaustyyppisiä muuttujia (samoin kuin `ArrayList`). Java muuntaa alkeistyyppiset muuttujat viittaustyyppisiksi käytännössä kaikkia Javan valmiita tietorakenteita (kuten ArrayList ja HashMap) käytettäessä. Vaikka luku `1` voidaan esittää alkeistyyppisen muuttujan `int` arvona, tulee sen tyypiksi määritellä `Integer` ArrayListissä ja HashMapissa. -->

A hash map expects that only reference-variables are added to it (in the same way that `ArrayList` does). Java converts primitive variables to their corresponding reference-types when using any Java's built in data structures (such as ArrayLisr and HashMap). Although the value `1` can be represented as a value of the primitive `int` variable, its type should be defined as `Integer` when using ArrayLists and HashMaps.
A hash map expects that only reference-variables are added to it (in the same way that `ArrayList` does). Java converts primitive variables to their corresponding reference-types when using any Java's built in data structures (such as ArrayList and HashMap). Although the value `1` can be represented as a value of the primitive `int` variable, its type should be defined as `Integer` when using ArrayLists and HashMaps.

<!-- ```java
HashMap<Integer, String> hashmap = new HashMap<>(); // toimii
Expand Down
2 changes: 1 addition & 1 deletion data/part-8/3-similarity-of-objects.md
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,7 @@ Jotta HashMap toimisi haluamallamme tavalla, eli palauttaisi lainaajan kun avaim

Olemme aiemmin käyttäneet `String`-olioita menestyksekkäästi HashMapin avaimena, joten voimme päätellä että `String`-luokassa on oma järkevästi toimiva `hashCode`-toteutus. _Delegoidaan_, eli siirretään laskemisvastuu `String`-oliolle. -->

We find the borrower when searching for the same object that was given as a key to the hash map's `put` method. However, when searching by the exact same book but with a different object,a borrwer isn't found, and we get the _null_ reference instead. The reason lies in the default implementation of the `hashCode` method in the `Object` class. The default implementation creates a `hashCode` value based on the object's reference, which means that books having the same content that are nonetheless different objects get different results from the hashCode method. As such, the object is not being searched for in the right place.
We find the borrower when searching for the same object that was given as a key to the hash map's `put` method. However, when searching by the exact same book but with a different object, a borrower isn't found, and we get the _null_ reference instead. The reason lies in the default implementation of the `hashCode` method in the `Object` class. The default implementation creates a `hashCode` value based on the object's reference, which means that books having the same content that are nonetheless different objects get different results from the hashCode method. As such, the object is not being searched for in the right place.

For the HashMap to work in the way we want it to, that is, to return the borrower when given an object with the correct _content_ (not necessarily the same object as the original key), the class that the key belongs to must overwrite the `hashCode` method in addition to the `equals` method. The method must be overwritten so that it gives the same numerical result for all objects with the same content. Also, some objects with different contents may get the same result from the hashCode method. However, with the HashMap's performance in mind, it is essential that objects with different contents get the same hash value as rarely as possible.

Expand Down
4 changes: 2 additions & 2 deletions data/part-9/1-inheritance.md
Original file line number Diff line number Diff line change
Expand Up @@ -556,7 +556,7 @@ System.out.println("opintopisteitä "+ olli.opintopisteita());
Student ollie = new Student("Ollie", "6381 Hollywood Blvd. Los Angeles 90028");
System.out.println(ollie);
System.out.println("Study credits " + ollie.credits());
olli.study();
ollie.study();
System.out.println("Study credits "+ ollie.credits());
```

Expand Down Expand Up @@ -595,7 +595,7 @@ System.out.println(olli);
```java
Student ollie = new Student("Ollie", "6381 Hollywood Blvd. Los Angeles 90028");
System.out.println(ollie);
olli.study();
ollie.study();
System.out.println(ollie);
```

Expand Down