Skip to content
Snippets Groups Projects
Commit 9a28c603 authored by Vesa Lappalainen's avatar Vesa Lappalainen :bicyclist:
Browse files

ht6 alku

parent 8a415f01
No related branches found
No related tags found
No related merge requests found
0 * 5 = 0
1 * 5 = 5
2 * 5 = 10
3 * 5 = 15
4 * 5 = 20
5 * 5 = 25
6 * 5 = 30
7 * 5 = 35
8 * 5 = 40
9 * 5 = 45
......@@ -43,7 +43,7 @@ public class Kertotaulu7 {
if (args.length > 0 ) tiedNimi = args[0];
try (PrintStream fo = new PrintStream(new FileOutputStream(tiedNimi, true))) {
int kerroin = 5;
for (int i = 0; i <= 10; i++)
for (int i = 0; i < 10; i++)
fo.printf("%2d * %d = %3d\n", i, kerroin, i * kerroin);
} catch (FileNotFoundException ex) {
System.err.println("Tiedosto ei aukea: " + ex.getMessage());
......
package tiedosto.test;
// Generated by ComTest BEGIN
import java.io.IOException;
import fi.jyu.mit.ohj2.VertaaTiedosto;
import static org.junit.Assert.*;
import org.junit.*;
import static tiedosto.Kertotaulu7.*;
// Generated by ComTest END
/**
* Test class made by ComTest
* @version 2024.03.05 13:05:55 // Generated by ComTest
*
*/
@SuppressWarnings({ "all" })
public class Kertotaulu7Test {
// Generated by ComTest BEGIN
/**
* testMain18
* @throws IOException when error
*/
@Test
public void testMain18() throws IOException { // Kertotaulu7: 18
String tiednimi = "kertotaulu7koe.txt";
VertaaTiedosto.tuhoaTiedosto(tiednimi);
main(new String[]{tiednimi});
String tulos = " 0 * 5 = 0\n"+
" 1 * 5 = 5\n"+
" 2 * 5 = 10\n"+
" 3 * 5 = 15\n"+
" 4 * 5 = 20\n"+
" 5 * 5 = 25\n"+
" 6 * 5 = 30\n"+
" 7 * 5 = 35\n"+
" 8 * 5 = 40\n"+
" 9 * 5 = 45\n";
assertEquals("From: Kertotaulu7 line: 35", null, VertaaTiedosto.vertaaFileString(tiednimi,tulos));
main(new String[]{tiednimi});
assertEquals("From: Kertotaulu7 line: 37", null, VertaaTiedosto.vertaaFileString(tiednimi,tulos+tulos));
VertaaTiedosto.tuhoaTiedosto(tiednimi);
} // Generated by ComTest END
}
\ No newline at end of file
......@@ -19,3 +19,13 @@
8 * 5 = 40
9 * 5 = 45
10 * 5 = 50
0 * 5 = 0
1 * 5 = 5
2 * 5 = 10
3 * 5 = 15
4 * 5 = 20
5 * 5 = 25
6 * 5 = 30
7 * 5 = 35
8 * 5 = 40
9 * 5 = 45
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment