diff options
author | Julian T <julian@jtle.dk> | 2020-09-17 11:29:50 +0200 |
---|---|---|
committer | Julian T <julian@jtle.dk> | 2020-09-17 11:29:50 +0200 |
commit | 5de991dd326103647b28e7d95b92b32a9e1671b9 (patch) | |
tree | a66b2976081338deae84f2cc25fde9beabbca824 /sem5/oop/m5 | |
parent | d285183c42f5d377b197bd0efab3bb20b240ef34 (diff) |
Added m5 assignments
Diffstat (limited to 'sem5/oop/m5')
-rw-r--r-- | sem5/oop/m5/opg1/.classpath | 6 | ||||
-rw-r--r-- | sem5/oop/m5/opg1/.gitignore | 1 | ||||
-rw-r--r-- | sem5/oop/m5/opg1/.project | 17 | ||||
-rw-r--r-- | sem5/oop/m5/opg1/src/Main.java | 35 | ||||
-rw-r--r-- | sem5/oop/m5/opg2/.classpath | 6 | ||||
-rw-r--r-- | sem5/oop/m5/opg2/.gitignore | 1 | ||||
-rw-r--r-- | sem5/oop/m5/opg2/.project | 17 | ||||
-rw-r--r-- | sem5/oop/m5/opg2/src/Main.java | 10 | ||||
-rw-r--r-- | sem5/oop/m5/opg2/src/PrintThread.java | 20 |
9 files changed, 113 insertions, 0 deletions
diff --git a/sem5/oop/m5/opg1/.classpath b/sem5/oop/m5/opg1/.classpath new file mode 100644 index 0000000..fb50116 --- /dev/null +++ b/sem5/oop/m5/opg1/.classpath @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="UTF-8"?> +<classpath> + <classpathentry kind="src" path="src"/> + <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> + <classpathentry kind="output" path="bin"/> +</classpath> diff --git a/sem5/oop/m5/opg1/.gitignore b/sem5/oop/m5/opg1/.gitignore new file mode 100644 index 0000000..ae3c172 --- /dev/null +++ b/sem5/oop/m5/opg1/.gitignore @@ -0,0 +1 @@ +/bin/ diff --git a/sem5/oop/m5/opg1/.project b/sem5/oop/m5/opg1/.project new file mode 100644 index 0000000..8c2b620 --- /dev/null +++ b/sem5/oop/m5/opg1/.project @@ -0,0 +1,17 @@ +<?xml version="1.0" encoding="UTF-8"?> +<projectDescription> + <name>mm5opg1</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/m5/opg1/src/Main.java b/sem5/oop/m5/opg1/src/Main.java new file mode 100644 index 0000000..97f992d --- /dev/null +++ b/sem5/oop/m5/opg1/src/Main.java @@ -0,0 +1,35 @@ +import javax.swing.JOptionPane; +import javax.swing.JFrame; +import java.nio.file.Files; +import java.nio.file.Path; +import java.io.IOException; + +class PaneThing { + JFrame f; + public PaneThing(String fname) throws IOException { + String content = Files.readString(Path.of(fname)); + + + f = new JFrame(); + JOptionPane.showMessageDialog(f, content); + } +} + +public class Main { + + public static void main(String[] args) { + + String fname = "hej.txt"; + if (args.length > 0) { + fname = args[0]; + } + + try { + PaneThing pt = new PaneThing(fname); + } catch (Exception e) { + System.err.printf("error: %s%n", e); + System.exit(1); + } + } + +} diff --git a/sem5/oop/m5/opg2/.classpath b/sem5/oop/m5/opg2/.classpath new file mode 100644 index 0000000..fb50116 --- /dev/null +++ b/sem5/oop/m5/opg2/.classpath @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="UTF-8"?> +<classpath> + <classpathentry kind="src" path="src"/> + <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> + <classpathentry kind="output" path="bin"/> +</classpath> diff --git a/sem5/oop/m5/opg2/.gitignore b/sem5/oop/m5/opg2/.gitignore new file mode 100644 index 0000000..ae3c172 --- /dev/null +++ b/sem5/oop/m5/opg2/.gitignore @@ -0,0 +1 @@ +/bin/ diff --git a/sem5/oop/m5/opg2/.project b/sem5/oop/m5/opg2/.project new file mode 100644 index 0000000..d5b0073 --- /dev/null +++ b/sem5/oop/m5/opg2/.project @@ -0,0 +1,17 @@ +<?xml version="1.0" encoding="UTF-8"?> +<projectDescription> + <name>mm5opg2</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/m5/opg2/src/Main.java b/sem5/oop/m5/opg2/src/Main.java new file mode 100644 index 0000000..26b95b3 --- /dev/null +++ b/sem5/oop/m5/opg2/src/Main.java @@ -0,0 +1,10 @@ + +public class Main { + + public static void main(String[] args) { + for(int i=0;i<args.length;i++) { + new PrintThread( args[i] ).start(); + } + } + +} diff --git a/sem5/oop/m5/opg2/src/PrintThread.java b/sem5/oop/m5/opg2/src/PrintThread.java new file mode 100644 index 0000000..50b8425 --- /dev/null +++ b/sem5/oop/m5/opg2/src/PrintThread.java @@ -0,0 +1,20 @@ +public class PrintThread extends Thread { + private int sleepTime; + + public PrintThread(String id ) + { + super(id); + sleepTime = (int) ( Math.random() * 5000 ); + System.out.println( "Name: " + getName() +" Sleep: " + sleepTime ); + } + + public void run() + { + try { + sleep( sleepTime ); + } + catch ( InterruptedException exception ) {} + System.out.println( "Thread " + getName() ); + } + +}
\ No newline at end of file |