Skip to content

Commit 267044b

Browse files
committed
Merge branch 'master' of github.com:rage/programming-20
2 parents 8282732 + e7866ab commit 267044b

File tree

3 files changed

+537
-212
lines changed

3 files changed

+537
-212
lines changed

data/osa-1/2-printing.md

Lines changed: 40 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ path: '/osa-1/2-printing'
33
title: 'Printing'
44
hidden: false
55
---
6+
67
<!-- ---
78
path: '/osa-1/2-tulostaminen'
89
title: 'Tulostaminen'
@@ -20,8 +21,8 @@ hidden: false
2021
<text-box variant='learningObjectives' name='Learning Objectives'>
2122

2223
- 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.
2526

2627
<!-- </text-box>
2728
@@ -39,7 +40,7 @@ Hei maailma!
3940

4041
</text-box>
4142

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".
4344

4445
```java
4546
System.out.println("Hello world!");
@@ -51,14 +52,13 @@ Hello world!
5152

5253
</sample-output>
5354

54-
5555
<!-- 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.
5656
5757
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!". -->
5858

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.
6060

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!".
6262

6363
<!-- ```java
6464
System.out.println("Hei vaan!");
@@ -94,9 +94,9 @@ public class Esimerkki {
9494
}
9595
``` -->
9696

97-
## Code boilerplate
97+
## Program Frame
9898

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`).
100100

101101
```java
102102
public class Example {
@@ -118,7 +118,7 @@ Tulostettava teksti
118118
119119
-->
120120

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:
122122

123123
<sample-output>
124124

@@ -149,26 +149,25 @@ public class Esimerkki {
149149

150150
<text-box variant="hint" name="Examples in material and code boilerplate">
151151

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.
153153

154154
```java
155155
System.out.println("Hello world");
156156
```
157157

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.
159159

160160
```java
161161
public class Example {
162162
public static void main(String[] args) {
163-
// Here you write the senteces the program uses
163+
// Here goes the statements used by the program
164164
System.out.println("Hello world!");
165165
}
166166
}
167167
```
168168

169169
</text-box>
170170

171-
172171
<!-- Alla on kurssin toinen ohjelmointitehtävä. Mikäli haluat, voit katsoa jo nyt alta olevalta videolta miten tehtävä ratkaistaan.
173172
174173
<youtube id="-DzOKI6iH5w"></youtube>
@@ -198,14 +197,15 @@ Kun olet tehnyt tehtävän ja huomaat, että ohjelma tulostaa halutun merkkijono
198197
</programming-exercise>
199198
-->
200199

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).
201+
202+
<!-- TODO video englanniksi? -->
202203

203-
TODO video englanniksi?
204204
<youtube id="-DzOKI6iH5w"></youtube>
205205

206206
<programming-exercise name='Ada Lovelace' tmcname='part01-Part01_02.AdaLovelace'>
207207

208-
In the exercise template there is the following code boilerplate:
208+
The exercise template has the following frame:
209209

210210
```java
211211
public class AdaLovelace {
@@ -215,20 +215,19 @@ public class AdaLovelace {
215215
}
216216
}
217217
```
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:
219220

220221
<sample-output>
221222

222223
Ada Lovelace
223224

224225
</sample-output>
225226

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.
227228

228229
</programming-exercise>
229230

230-
231-
232231
<!-- <text-box variant='hint' name='Ohjelman suorittaminen'>
233232
234233
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
245244

246245
<text-box variant='hint' name='Running the program'>
247246

248-
You can run the program in TMC by pressing the green play button 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.
249248

250249
TODO: tähän kuva TMC:stä (highlightattuna run-nappi).
251250

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.
253252

254253
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.
255254

@@ -279,7 +278,7 @@ Hei maailma!
279278
280279
</sample-output> -->
281280

282-
## Printing multiple lines
281+
## Printing Multiple Lines
283282

284283
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.
285284

@@ -291,6 +290,7 @@ public class Ohjelma {
291290
}
292291
}
293292
```
293+
294294
Above program will print:
295295

296296
<sample-output>
@@ -348,10 +348,9 @@ ohjelma
348348
349349
</programming-exercise> -->
350350

351-
352351
<programming-exercise name='Once upon a time' tmcname='part01-Part01_03.OnceUponATime'>
353352

354-
In the exercise template there is the following code boilerplate:
353+
The exercise template comes with the following code frame:
355354

356355
```java
357356
public class OnceUponATime {
@@ -374,7 +373,6 @@ a program
374373

375374
</programming-exercise>
376375

377-
378376
<!-- <text-box variant='hint' name='Lyhenne "sout"'>
379377
380378
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
387385

388386
<text-box>
389387

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.
391389

392390
Animation below illustrates the use of sout-command. First user writes sout and then pressed tabulator. A Magic Trick!
393391

394392
![](../img/sout.gif)
395393

396394
</text-box>
397395

398-
399396
<!-- <programming-exercise name='Olipa kerran maa' tmcname='osa01-Osa01_04.OlipaKerranMaa'>
400397
401398
Tehtäväpohjassa on seuraavanlainen ohjelmarunko:
@@ -422,7 +419,7 @@ maa
422419

423420
<programming-exercise name='Dinosaur' tmcname='part01-Part01_04.Dinosaur'>
424421

425-
In the exercise template there is the following code boilerplate:
422+
The exercise comes ready with the following template:
426423

427424
```java
428425
public class Dinosaur {
@@ -444,7 +441,6 @@ a dinosaur
444441

445442
</programming-exercise>
446443

447-
448444
<!-- ## Terminologiaa ja koodin kommentointi
449445
450446
### Komennon parametrit
@@ -473,15 +469,15 @@ Vaikka yllä oleva esimerkki toimii, on rivinvaihtojen käyttö tärkeää muita
473469
TODO: quiz, jossa kysytään että mistä tietyssä termissä on kyse
474470
-->
475471

476-
## Terminology and commenting code
472+
## Terminology and Commenting Code
477473

478-
### Commands parameters
474+
### Command parameters
479475

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")`.
481477

482478
### Semicolon separates commands
483479

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.
485481

486482
```java
487483
System.out.println("Hello "); System.out.println("world"); System.out.println("!\n");
@@ -495,10 +491,9 @@ world
495491

496492
</sample-output>
497493

498-
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.
501495

496+
<!-- TODO: quiz, jossa kysytään että mistä tietyssä termissä on kyse -->
502497

503498
<!-- ### Kommentit
504499
@@ -530,30 +525,30 @@ Esimerkin alin rivi esittelee erityisen kätevän käyttökohteen kommenteille.
530525

531526
### Comments
532527

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.
534529

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.
537532

538533
Below is an example of a program where both are used.
539534

540535
```java
541536
public class Comments {
542537
public static void main(String[] args) {
543-
// print
538+
// Printing
544539
System.out.println("Text to print");
545540
System.out.println("More text to print!");
546541
/* Next:
547-
- more about printing
542+
- more on printing
548543
- more practice
549544
- variables
550545
- ...
551546
*/
552-
System.out.println("Other text to print");
547+
System.out.println("Some other text to print");
553548
}
554549
}
555550
```
556551

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.
558553

559-
TODO: Tää ei nyt oikei käy järkeen?
554+
<!-- TODO: Tää ei nyt oikei käy järkeen? -->

0 commit comments

Comments
 (0)