aboutsummaryrefslogtreecommitdiff
path: root/sem5/oop/m2/Opg1
diff options
context:
space:
mode:
Diffstat (limited to 'sem5/oop/m2/Opg1')
-rw-r--r--sem5/oop/m2/Opg1/.classpath10
-rw-r--r--sem5/oop/m2/Opg1/.gitignore1
-rw-r--r--sem5/oop/m2/Opg1/.project17
-rw-r--r--sem5/oop/m2/Opg1/hej.txt10
-rw-r--r--sem5/oop/m2/Opg1/src/Main.java38
5 files changed, 76 insertions, 0 deletions
diff --git a/sem5/oop/m2/Opg1/.classpath b/sem5/oop/m2/Opg1/.classpath
new file mode 100644
index 0000000..adeb0a3
--- /dev/null
+++ b/sem5/oop/m2/Opg1/.classpath
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER">
+ <attributes>
+ <attribute name="module" value="true"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/sem5/oop/m2/Opg1/.gitignore b/sem5/oop/m2/Opg1/.gitignore
new file mode 100644
index 0000000..ae3c172
--- /dev/null
+++ b/sem5/oop/m2/Opg1/.gitignore
@@ -0,0 +1 @@
+/bin/
diff --git a/sem5/oop/m2/Opg1/.project b/sem5/oop/m2/Opg1/.project
new file mode 100644
index 0000000..1b0d3fd
--- /dev/null
+++ b/sem5/oop/m2/Opg1/.project
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>Opg1</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
diff --git a/sem5/oop/m2/Opg1/hej.txt b/sem5/oop/m2/Opg1/hej.txt
new file mode 100644
index 0000000..d8c6033
--- /dev/null
+++ b/sem5/oop/m2/Opg1/hej.txt
@@ -0,0 +1,10 @@
+1 2 3 4 5 6 7 8 9 10
+11 12 13 14 15 16 17 18 19 20
+21 22 23 24 25 26 27 28 29 30
+31 32 33 34 35 36 37 38 39 40
+41 42 43 44 45 46 47 48 49 50
+51 52 53 54 55 56 57 58 59 60
+61 62 63 64 65 66 67 68 69 70
+71 72 73 74 75 76 77 78 79 80
+81 82 83 84 85 86 87 88 89 90
+91 92 93 94 95 96 97 98 99 100
diff --git a/sem5/oop/m2/Opg1/src/Main.java b/sem5/oop/m2/Opg1/src/Main.java
new file mode 100644
index 0000000..179e678
--- /dev/null
+++ b/sem5/oop/m2/Opg1/src/Main.java
@@ -0,0 +1,38 @@
+import java.io.FileWriter;
+import java.io.IOException;
+
+public class Main {
+
+ static void writeLines(String name) throws IOException{
+ FileWriter f = null;
+ try {
+ f = new FileWriter(name);
+
+ for (int i = 1; i <= 100; i++) {
+ f.write(String.format("%-3d ", i));
+ if (i % 10 == 0) {
+ f.write(System.lineSeparator());
+ }
+ }
+ } finally {
+ if (f != null) {
+ f.close();
+ }
+ }
+ }
+
+ public static void main(String[] args) {
+ String name = "hej.txt";
+ if (args.length > 0) {
+ name = args[0];
+ }
+
+ System.out.printf("Writing to %s%n", name);
+ try {
+ writeLines(name);
+ } catch(IOException e) {
+ System.err.printf("Failed with: %s%n", e);
+ }
+ }
+
+}