You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- You will learn to write a program that prints text.
23
-
- You will get acquainted with executing programs
24
-
- You will know what the term parameter means
24
+
- You will become familiar with executing programs.
25
+
- You will know what the term parameter means.
25
26
26
27
<!-- </text-box>
27
28
@@ -39,7 +40,7 @@ Hei maailma!
39
40
40
41
</text-box>
41
42
42
-
Print command `System.out.println("Hello world");` prints text "Hello world".
43
+
The print command `System.out.println("Hello world");` prints the text "Hello world".
43
44
44
45
```java
45
46
System.out.println("Hello world!");
@@ -51,14 +52,13 @@ Hello world!
51
52
52
53
</sample-output>
53
54
54
-
55
55
<!-- Yllä olevan tekstialueen näköiset kohdat materiaalissa kuvaavat koodiesimerkin tuottamaan tulostuksen. Yllä ohjelma tuottaisi siis tulostuksen "Hei maailma!". Voit kokeilla kaikkia materiaalin esimerkkejä ohjelmointiympäristössä olevassa "Hiekkalaatikko"-nimisessä tehtäväpohjassa.
56
56
57
57
Tulostuskomennon avulla tulostettavaa tekstiä voi vaihtaa mielivaltaisesti, kunhan komento `System.out.println("mielivaltainen teksti");` -- eli `System` piste `out` piste `println` sulut auki `(` "teksti" sulut kiinni `)` ja puolipiste `;` pysyy muuttumattomana. Alla oleva komento tulostaa tekstin "Hei vaan!". -->
58
58
59
-
In the material, text areas like above show the output of the code examples. Program above would then produce output "Hello world!". You can try out any code examples TODO: viimeistele tää lause...
59
+
Sections in the material similar to the text area above demonstrate an output produced by some example code. Accordingly, the above program would produce the print output "Hello World!". You can try all of the material's examples in the exercise template named "Sandbox", which is found in the programming environment.
60
60
61
-
Text printed with the print command can be changed arbitrarily as long as the command `System.out.println("arbitary text");` -- or`System`point`out`point`println`parenthehes open `(` "text" parentheses close `)` and semicolon `;`stays constant. Below command will print text "Hello there!".
61
+
Text printed with the print command can be changed arbitrarily as long as the command `System.out.println("arbitary text");` -- i.e.`System`dot`out`dot`println` open parentheses `(` "the text" close parentheses `)` and semicolon `;`remains unchanged. The command below command will print the text "Hello there!".
62
62
63
63
<!-- ```java
64
64
System.out.println("Hei vaan!");
@@ -94,9 +94,9 @@ public class Esimerkki {
94
94
}
95
95
``` -->
96
96
97
-
## Code boilerplate
97
+
## Program Frame
98
98
99
-
To work, our programs need a code boilerplate as below. The name of the boilerplate, here `Example`, corresponds to the file name in source (e.g. `Example.java`).
99
+
Our programs have to be written within a program frame, such as the one below, for them to work. The name of the frame, `Example` in this case, corresponds to the file name that contains the source code (e.g. `Example.java`).
100
100
101
101
```java
102
102
publicclassExample {
@@ -118,7 +118,7 @@ Tulostettava teksti
118
118
119
119
-->
120
120
121
-
Execution of the program starts after the line `public static void main(string[] args) {` and ends at the closing curly bracket `}`. Commands are executed one line at a time. We will get know the meaning of the words `public class` and `public static void` later. In the above example, `System.out.println("Text to be printed")` is the only command to be executed and its output is:
121
+
Execution of the program starts from the line that follows `public static void main(string[] args) {`, and ends at the closing curly bracket `}`. Commands are executed one line at a time. We will get know the meaning of the words `public class` and `public static void` later on. In the above example, `System.out.println("Text to be printed")` is the only command to be executed and its output is:
122
122
123
123
<sample-output>
124
124
@@ -149,26 +149,25 @@ public class Esimerkki {
149
149
150
150
<text-boxvariant="hint"name="Examples in material and code boilerplate">
151
151
152
-
Not every example in material have the boilerplate, but you can assume that it is always needed. The examples can have only one line like printing example below.
152
+
Not all of the material examples use a template, but you should assume that one is always needed. The examples can consist of only a single line, such as the printing example below.
153
153
154
154
```java
155
155
System.out.println("Hello world");
156
156
```
157
157
158
-
In a real java program the example above looks like the following.
158
+
In reality however, the example above looks like the following when written in Java.
159
159
160
160
```java
161
161
publicclassExample {
162
162
publicstaticvoidmain(String[] args) {
163
-
// Here you write the senteces the program uses
163
+
// Here goes the statements used by the program
164
164
System.out.println("Hello world!");
165
165
}
166
166
}
167
167
```
168
168
169
169
</text-box>
170
170
171
-
172
171
<!-- Alla on kurssin toinen ohjelmointitehtävä. Mikäli haluat, voit katsoa jo nyt alta olevalta videolta miten tehtävä ratkaistaan.
173
172
174
173
<youtube id="-DzOKI6iH5w"></youtube>
@@ -198,14 +197,15 @@ Kun olet tehnyt tehtävän ja huomaat, että ohjelma tulostaa halutun merkkijono
198
197
</programming-exercise>
199
198
-->
200
199
201
-
Below is the second programming exercise of the course. If you want, you can now watch how to solve the exercise at video below.
200
+
You'll find the second programming exercise of the course below. If you want, you can watch the video linked below in advance to see how the exercise is solved (NB: currently only available in Finnish).
In the exercise template there is the following code boilerplate:
208
+
The exercise template has the following frame:
209
209
210
210
```java
211
211
publicclassAdaLovelace {
@@ -215,20 +215,19 @@ public class AdaLovelace {
215
215
}
216
216
}
217
217
```
218
-
Line "// Write your program here" is a _line comment_, which the computer doesn't take into account when executing the program. Add a new line below the line comment that prints a string "Ada Lovelace" and run the program. The output of the program should be as following:
218
+
219
+
The line "// Write your program here" is a _line comment_, which the computer ignores when executing the program. Add a new line below the line comment that prints the string "Ada Lovelace" and run the program. The output of the program should be:
219
220
220
221
<sample-output>
221
222
222
223
Ada Lovelace
223
224
224
225
</sample-output>
225
226
226
-
When you have finished the exercise and and prints the correct string, return the exercise to TMC. After this you can read more about [Ada Lovelace](https://en.wikipedia.org/wiki/Ada_Lovelace), who was one of the first programmers.
227
+
Once you've finished the exercise and see that it prints the correct string, return the exercise to TMC. Following that, you can read more about [Ada Lovelace](https://en.wikipedia.org/wiki/Ada_Lovelace), who was one of the first programmers.
Ohjelman suorittaminen tapahtuu TMC:ssä vihreää play-nappia painamalla tai valitsemalla TMC-valikosta vaihtoehdon "Run project".
@@ -245,11 +244,11 @@ Käytössämme oleva ohjelmointiympäristö kääntää ja suorittaa ohjelman yh
245
244
246
245
<text-boxvariant='hint'name='Running the program'>
247
246
248
-
You can run the program in TMC by pressing the green playbutton or by selecting "Run project" from TMC-menu.
247
+
You can run a program in TMC by pressing the green play-button, or by selecting "Run project" from the TMC-menu.
249
248
250
249
TODO: tähän kuva TMC:stä (highlightattuna run-nappi).
251
250
252
-
Running the program is easy, but there happens much under the surface. When you want to run the program, the source code is first compiled into Java bytecode. This is done with Javas own compiler, which also is a program. After this the program will be executed meaning the commands will be executed one by one by a Java-compiler which understands java bytecode.
251
+
Although running the program is straightforward, a lot happens behind the scenes. When a program is run, the source code is first compiled into Java bytecode. This compilation process is done by Java's own compiler, which itself is a program. Following that, the program gets executed, meaning the commands are executed one-by-one by a Java-interpreter that is able to read Java bytecode.
253
252
254
253
This compile process affects how and when errors occur. When program is compiled before execution, the program used for compiling can search errors from your program. This affects also what tips the programming environment can offer so that a programmer can get feedback about possible errors instantly.
255
254
@@ -279,7 +278,7 @@ Hei maailma!
279
278
280
279
</sample-output> -->
281
280
282
-
## Printing multiple lines
281
+
## Printing Multiple Lines
283
282
284
283
Programs are constructed command by command where each command comes on a new line. In the example below, command `System.out.println` appears twice, which means that two print commands are being executed in the program.
285
284
@@ -291,6 +290,7 @@ public class Ohjelma {
291
290
}
292
291
}
293
292
```
293
+
294
294
Above program will print:
295
295
296
296
<sample-output>
@@ -348,10 +348,9 @@ ohjelma
348
348
349
349
</programming-exercise> -->
350
350
351
-
352
351
<programming-exercisename='Once upon a time'tmcname='part01-Part01_03.OnceUponATime'>
353
352
354
-
In the exercise template there is the following code boilerplate:
353
+
The exercise template comes with the following code frame:
Komennon `System.out.println("...")` kirjoittaminen voi olla melko työlästä. Kokeile kirjoittaa NetBeans:iin (main:in sisään) tyhjälle riville _sout_ ja paina tabulaattoria (näppäin q:n vasemmalla puolella). Mitä tapahtuu? Tämä pieni apuväline säästänee jatkossa runsaasti aikaasi.
@@ -387,15 +385,14 @@ Alla oleva animaatio kuvaa sout-komennon käyttöä. Kun käyttäjä on kirjoitt
387
385
388
386
<text-box>
389
387
390
-
Writing the command `System.out.println("...") can be pretty cumbersome. In NetBeans try to write on a blank line (in main) __sout__ and press tabulator (key left to q). What happens? This small tool will propably save much of your time.
388
+
Writing the command `System.out.println("...") can be pretty cumbersome. In NetBeans try to write on a blank line (in main) **sout** and press tabulator (key left to q). What happens? This small tool will propably save much of your time.
391
389
392
390
Animation below illustrates the use of sout-command. First user writes sout and then pressed tabulator. A Magic Trick!
393
391
394
392

395
393
396
394
</text-box>
397
395
398
-
399
396
<!-- <programming-exercise name='Olipa kerran maa' tmcname='osa01-Osa01_04.OlipaKerranMaa'>
In the exercise template there is the following code boilerplate:
422
+
The exercise comes ready with the following template:
426
423
427
424
```java
428
425
publicclassDinosaur {
@@ -444,7 +441,6 @@ a dinosaur
444
441
445
442
</programming-exercise>
446
443
447
-
448
444
<!-- ## Terminologiaa ja koodin kommentointi
449
445
450
446
### Komennon parametrit
@@ -473,15 +469,15 @@ Vaikka yllä oleva esimerkki toimii, on rivinvaihtojen käyttö tärkeää muita
473
469
TODO: quiz, jossa kysytään että mistä tietyssä termissä on kyse
474
470
-->
475
471
476
-
## Terminology and commenting code
472
+
## Terminology and Commenting Code
477
473
478
-
### Commands parameters
474
+
### Command parameters
479
475
480
-
Information you print with print command is given as a __parameter__ bt adding it inside the parenteheses`()`after the command. For example, givin`Hi` as a parameter for `System.out.println` command is done like this: `System.out.println("Hi)`.
476
+
The information to be printed by the print command, i.e. its **parameters**, are passed to it by placing them inside the parentheses`()`that follow the command. For example, passing`Hi` as a parameter to the `System.out.println` command is done like this: `System.out.println("Hi")`.
481
477
482
478
### Semicolon separates commands
483
479
484
-
Commands are separated with a semicolon `;`. we could actually write almost everyting on a single line. However, that would not be very understandable.
480
+
Commands are separated with a semicolon `;`. We could, if we wanted to, write almost everything on a single line. However, that would be difficult to understand.
Even tho above example does work, it is important to use line breaks for other programmers. Then the one reading the program knows that only one concretic thing is done on each line.
499
-
500
-
TODO: quiz, jossa kysytään että mistä tietyssä termissä on kyse
494
+
Although the above example works, it's important to be considerate of other programmers and to use line breaks. That way, anyone reading the program knows that each line does only a single concrete thing.
501
495
496
+
<!-- TODO: quiz, jossa kysytään että mistä tietyssä termissä on kyse -->
502
497
503
498
<!-- ### Kommentit
504
499
@@ -530,30 +525,30 @@ Esimerkin alin rivi esittelee erityisen kätevän käyttökohteen kommenteille.
530
525
531
526
### Comments
532
527
533
-
You can comment source code to clarify it or to add notes. There are two ways to do this.
528
+
Source code can be commented to clarify it or to add notes. There are two ways to do this.
534
529
535
-
-One line comments are started with two slashes `//`. Everything following on the same line is interpreted as a comment.
536
-
-Multiline comments are started with one slash and an asterisk `/*` and ended with an asterisk and a slash `*/`. Everything between them is interpreted as a comment.
530
+
-Single-line comments are marked with two slashes `//`. Everything following them on the same line is interpreted as a comment.
531
+
-Multi-line comments are marked with a slash and an asterisk `/*`, and closed with an asterisk followed by a slash `*/`. Everything between them is interpreted as a comment.
537
532
538
533
Below is an example of a program where both are used.
539
534
540
535
```java
541
536
publicclassComments {
542
537
publicstaticvoidmain(String[] args) {
543
-
//print
538
+
//Printing
544
539
System.out.println("Text to print");
545
540
System.out.println("More text to print!");
546
541
/* Next:
547
-
- more about printing
542
+
- more on printing
548
543
- more practice
549
544
- variables
550
545
- ...
551
546
*/
552
-
System.out.println("Other text to print");
547
+
System.out.println("Some other text to print");
553
548
}
554
549
}
555
550
```
556
551
557
-
The last line of the example presents a particularly handy use for comments. You don't need to remove any source code you have written if you want to try something.
552
+
The last line of the example shows a particularly handy use-case for comments. The source code does not need to be removed to temporarily try out something.
0 commit comments