commit dd0352bf1404b655019e51be062543b4aa4d5f6a Author: Arti Zirk Date: Thu Oct 15 14:42:32 2015 +0300 Esimene Õpigrupp diff --git a/.classpath b/.classpath new file mode 100644 index 0000000..fceb480 --- /dev/null +++ b/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e660fd9 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +bin/ diff --git a/.project b/.project new file mode 100644 index 0000000..cc98a4d --- /dev/null +++ b/.project @@ -0,0 +1,17 @@ + + + opigrupp + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..3a21537 --- /dev/null +++ b/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/src/opigrupp1/Meetotid.java b/src/opigrupp1/Meetotid.java new file mode 100644 index 0000000..5fa38c6 --- /dev/null +++ b/src/opigrupp1/Meetotid.java @@ -0,0 +1,22 @@ +package opigrupp1; + +public class Meetotid /* see on nimi */ { + + private static int tereTere() { + return 1; + } + + public static int veelTere(int saadetis){ + saadetis = saadetis + 1; + return saadetis; + } + + public static void main(String[] args) { + int mingimuutuja = tereTere(); + int veelMuutuja = veelTere(5); + System.out.println(mingimuutuja); + System.out.println(veelMuutuja); + } + + +} diff --git a/src/opigrupp1/Muutujad.java b/src/opigrupp1/Muutujad.java new file mode 100644 index 0000000..4876e58 --- /dev/null +++ b/src/opigrupp1/Muutujad.java @@ -0,0 +1,101 @@ +package opigrupp1; + +import java.util.InputMismatchException; +import java.util.Scanner; + +public class Muutujad { + + public static void main(String[] args) { + int number; + double komakohaga = 5.6; + boolean tingimus = false; + char minumuutuja = 'a'; + + String minuTekst = "Tere maailm!"; + + int a = 5; + double b = 2; + double c = a / b; + //System.out.printf("%d", c); + //System.out.printf("%.3f", c); + //System.out.printf(" %s rebane", minuTekst); + + + + + + + + + + + + + + int[] veelmassiive; + int[] massiiv = {1, 2, 3, 99}; + //int[] j2rgminemassiiv = new int[] {1,3,4}; + int[][] kaksDMassiiv = { + {1, 2}, + {3, 4}, + {5, 6} + }; + + //System.out.println(kaksDMassiiv[0][1]); //prints 2 + + String[] minuLaheTekst = new String[5]; + + // lisame 1. sahti teksti + minuLaheTekst[0] = "Kass"; + + // lisame 2. sahti teksti + minuLaheTekst[1] = "Tere Koer!"; + + // see ei toimi sest 42 ei ole String tüüp! + //minuLaheTekst[2] = 42; + + + massiiv[0] = 42; // esimese sahtli väärtus on 42 + massiiv[3] = 5; + massiiv[2] = 5*5; //kolmanda sahtli väärtus on 5 korda 5 + + + + + //System.out.println(massiiv[0] + " " + massiiv[3]); + + int[] kahegajaguvad = new int[100]; + + for(int i = 0; i < 100; i++){ + kahegajaguvad[i] = i; + } + + String minuTest = "salakala"; + + //System.out.println(minuTest.length()); + + Scanner input = new Scanner(System.in); + //System.out.print("input: "); + //int s = input.nextInt(); + int s = getInt(); + System.out.println(s); + + + } + + public static int getInt() { + int asdf; + for (asdf = -1; asdf != 2;) { + try { + Scanner input = new Scanner(System.in); + System.out.print("input: "); + asdf = input.nextInt(); + //break; // exit while + } catch(InputMismatchException e) { + //System.out.printf("u fuked up mate: %s", e); + } + } + return asdf; + } + +} \ No newline at end of file diff --git a/src/opigrupp1/kaksDMasiiv.java b/src/opigrupp1/kaksDMasiiv.java new file mode 100644 index 0000000..cacb641 --- /dev/null +++ b/src/opigrupp1/kaksDMasiiv.java @@ -0,0 +1,61 @@ +package opigrupp1; + +public class kaksDMasiiv { + + public static void main(String[] args) { + int[][] kaksDMassiiv = {{1, 2},{3, 4},{5, 6}}; + int[][] kaksDMassiiv2 = new int[3][2]; + + //System.out.println(kaksDMassiiv[0][1]); //prints 2 + //System.out.println(kaksDMassiiv[2][0]); //prints 5 + + + // = new int[7]; + int[] arvud = new int[]{1,3,0,5,0,6,0}; + + + int arv = 0; + //need kolm rida teevad sama asja + arv = arv + 1; + arv += 1; + arv++; + + arv = arv - 1; + arv -= 1; + arv--; + + arv = arv * 1; + arv *= 1; + // kolmandata varianti pole + + arv = arv / 1; + arv /= 1; + // kolmandata varianti pole ka siin + + // minimaalne for tsükkel + for (int i = 1; i < 10; i = i + 4) { + System.out.println(i); + } + //System.out.println(i); // see rida feilib sest i ei eksisteeri enam + + int mingi = 3; + switch (mingi) { + case 1: + System.out.println("kirjutati 1"); + break; + case 2: + // + } + + // leian mitu nulli on massiivis + int nullideArv = 0; + for(int i = 1; i < arvud.length; i = i + 2){ + if(arvud[i] == 0){ + //nullideArv = nullideArv + 1; + nullideArv++; + } + } + System.out.println("Nullide arv massiivis on " + nullideArv); + } + +}