diff --git a/ exercises/HelloWorld-Extended/logs.log b/ exercises/HelloWorld-Extended/logs.log
new file mode 100644
index 0000000..4224871
--- /dev/null
+++ b/ exercises/HelloWorld-Extended/logs.log
@@ -0,0 +1 @@
+INFO main ro.teamnet.hello.HelloWorld - INFO->Enters in sayHello() method from HelloWorld
diff --git a/ exercises/HelloWorld-Extended/pom.xml b/ exercises/HelloWorld-Extended/pom.xml
new file mode 100644
index 0000000..c8298b9
--- /dev/null
+++ b/ exercises/HelloWorld-Extended/pom.xml
@@ -0,0 +1,20 @@
+
+
+ 4.0.0
+
+ ro.teamnet.zerotohero
+ helloworld-extended
+ 1.0
+
+
+
+ ro.teamnet.zerotohero
+ helloworld-core
+ 1.0
+
+
+
+
+
\ No newline at end of file
diff --git a/ exercises/HelloWorld-Extended/src/main/java/ro/teamnet/hello2/HelloWorldExtended.java b/ exercises/HelloWorld-Extended/src/main/java/ro/teamnet/hello2/HelloWorldExtended.java
new file mode 100644
index 0000000..89eea8e
--- /dev/null
+++ b/ exercises/HelloWorld-Extended/src/main/java/ro/teamnet/hello2/HelloWorldExtended.java
@@ -0,0 +1,26 @@
+package ro.teamnet.hello2;
+
+import ro.teamnet.hello.HelloWorld;
+
+/**
+ * Created by Buli on 29.10.2014.
+ */
+public class HelloWorldExtended {
+
+ public HelloWorldExtended() {
+ }
+
+ public void extendSayHello(){
+ HelloWorld helloWorld = new HelloWorld();
+ helloWorld.sayHello();
+ System.out.println("The new Hello World");
+ }
+
+ public static void main(String[] Args){
+
+ HelloWorldExtended helloWorld = new HelloWorldExtended();
+ helloWorld.extendSayHello();
+ }
+
+
+}
diff --git a/ exercises/HelloWorldMain/logs.log b/ exercises/HelloWorldMain/logs.log
new file mode 100644
index 0000000..4aaa8bc
--- /dev/null
+++ b/ exercises/HelloWorldMain/logs.log
@@ -0,0 +1,11 @@
+DEBUG main ro.teamnet.hello.HelloWorld - DEBUG->Enters in sayHello() method from HelloWorld
+INFO main ro.teamnet.hello.HelloWorld - INFO->Enters in sayHello() method from HelloWorld
+INFO main ro.teamnet.hello.HelloWorld - INFO->Enters in sayHello() method from HelloWorld
+INFO main ro.teamnet.hello.HelloWorld - INFO->Enters in sayHello() method from HelloWorld
+DEBUG main ro.teamnet.hello.HelloWorld - DEBUG->Enters in sayHello() method from HelloWorld
+INFO main ro.teamnet.hello.HelloWorld - INFO->Enters in sayHello() method from HelloWorld
+INFO main ro.teamnet.hello.HelloWorld - INFO->Enters in sayHello() method from HelloWorld
+INFO main ro.teamnet.hello.HelloWorld - INFO->Enters in sayHello() method from HelloWorld
+INFO main ro.teamnet.hello.HelloWorld - INFO->Enters in sayHello() method from HelloWorld
+INFO main ro.teamnet.hello.HelloWorld - INFO->Enters in sayHello() method from HelloWorld
+INFO main ro.teamnet.hello.HelloWorld - INFO->Enters in sayHello() method from HelloWorld
diff --git a/ exercises/HelloWorldMain/pom.xml b/ exercises/HelloWorldMain/pom.xml
new file mode 100644
index 0000000..1609b45
--- /dev/null
+++ b/ exercises/HelloWorldMain/pom.xml
@@ -0,0 +1,74 @@
+
+
+ 4.0.0
+
+ ro.teamnet.zerotohero
+ helloworld-core
+ 1.0
+
+ A Maven project for displaying a Hello World Application
+ Hello World Project
+
+
+
+ log4j
+ log4j
+ 1.2.17
+
+
+
+ junit
+ junit
+ 4.11
+
+
+
+ com.oracle
+ ojdbc6
+ 11.2.0.3
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-source-plugin
+
+
+ attach-sources
+
+ jar
+
+
+
+
+
+
+ org.liquibase
+ liquibase-maven-plugin
+ 3.0.5
+
+ src/main/resources/liquibase_file.xml
+ oracle.jdbc.driver.OracleDriver
+ jdbc:oracle:thin:@10.6.33.102:1521:orcl
+ ZTH_01
+ passw0rd
+
+
+
+ process-resources
+
+ update
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/ exercises/HelloWorldMain/src/main/java/ro/teamnet/hello/HelloWorld.java b/ exercises/HelloWorldMain/src/main/java/ro/teamnet/hello/HelloWorld.java
new file mode 100644
index 0000000..f91c824
--- /dev/null
+++ b/ exercises/HelloWorldMain/src/main/java/ro/teamnet/hello/HelloWorld.java
@@ -0,0 +1,31 @@
+package ro.teamnet.hello;
+
+import org.apache.log4j.Logger;
+
+import java.io.IOException;
+
+/**
+ * Created by Buli on 29.10.2014.
+ */
+public class HelloWorld {
+
+ static final Logger logger = Logger.getLogger(HelloWorld.class.getName());
+
+ public void sayHello(){
+ int i=0;
+ System.out.println("Hello World!");
+ logger.debug("DEBUG->Enters in sayHello() method from HelloWorld");
+ logger.info("INFO->Enters in sayHello() method from HelloWorld");
+ }
+
+ public String returnHelloKey(){
+ return "Hello Key";
+ }
+
+ public static void main(String[] args) {
+ HelloWorld helloWorld = new HelloWorld();
+
+ helloWorld.sayHello();
+ }
+
+}
diff --git a/ exercises/HelloWorldMain/src/main/resources/liquibase_file.xml b/ exercises/HelloWorldMain/src/main/resources/liquibase_file.xml
new file mode 100644
index 0000000..f8e272c
--- /dev/null
+++ b/ exercises/HelloWorldMain/src/main/resources/liquibase_file.xml
@@ -0,0 +1,31 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/ exercises/HelloWorldMain/src/main/resources/log4j.properties b/ exercises/HelloWorldMain/src/main/resources/log4j.properties
new file mode 100644
index 0000000..7b64d41
--- /dev/null
+++ b/ exercises/HelloWorldMain/src/main/resources/log4j.properties
@@ -0,0 +1,17 @@
+log4j.rootLogger=info, stdout, R
+
+log4j.appender.stdout=org.apache.log4j.ConsoleAppender
+log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
+
+# Pattern to output the caller's file name and line number.
+log4j.appender.stdout.layout.ConversionPattern=%5p [%t] (%F:%L) - %m%n
+
+log4j.appender.R=org.apache.log4j.RollingFileAppender
+log4j.appender.R.File=logs.log
+
+log4j.appender.R.MaxFileSize=100KB
+# Keep one backup file
+log4j.appender.R.MaxBackupIndex=1
+
+log4j.appender.R.layout=org.apache.log4j.PatternLayout
+log4j.appender.R.layout.ConversionPattern=%p %t %c - %m%n
diff --git a/ exercises/HelloWorldMain/src/test/java/ro/teamnet/hello/HelloWorldTest.java b/ exercises/HelloWorldMain/src/test/java/ro/teamnet/hello/HelloWorldTest.java
new file mode 100644
index 0000000..e0c7da1
--- /dev/null
+++ b/ exercises/HelloWorldMain/src/test/java/ro/teamnet/hello/HelloWorldTest.java
@@ -0,0 +1,25 @@
+package ro.teamnet.hello;
+
+import org.junit.Test;
+
+/**
+ * Created by Buli on 29.10.2014.
+ */
+public class HelloWorldTest {
+
+ @Test
+ public void testSayHello(){
+ HelloWorld helloWorld = new HelloWorld();
+ helloWorld.sayHello();
+ }
+
+ @Test
+ public void testReturnHelloKey(){
+ HelloWorld helloWorld = new HelloWorld();
+ System.out.println("From Test: " + helloWorld.returnHelloKey());
+ assert helloWorld.returnHelloKey().equals("Hello Key");
+ }
+
+
+
+}
diff --git a/ exercises/HelloWorldMain/src/test/resources/log4j.properties b/ exercises/HelloWorldMain/src/test/resources/log4j.properties
new file mode 100644
index 0000000..7b64d41
--- /dev/null
+++ b/ exercises/HelloWorldMain/src/test/resources/log4j.properties
@@ -0,0 +1,17 @@
+log4j.rootLogger=info, stdout, R
+
+log4j.appender.stdout=org.apache.log4j.ConsoleAppender
+log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
+
+# Pattern to output the caller's file name and line number.
+log4j.appender.stdout.layout.ConversionPattern=%5p [%t] (%F:%L) - %m%n
+
+log4j.appender.R=org.apache.log4j.RollingFileAppender
+log4j.appender.R.File=logs.log
+
+log4j.appender.R.MaxFileSize=100KB
+# Keep one backup file
+log4j.appender.R.MaxBackupIndex=1
+
+log4j.appender.R.layout=org.apache.log4j.PatternLayout
+log4j.appender.R.layout.ConversionPattern=%p %t %c - %m%n
diff --git a/ exercises/HelloWorldMain/target/classes/liquibase_file.xml b/ exercises/HelloWorldMain/target/classes/liquibase_file.xml
new file mode 100644
index 0000000..f8e272c
--- /dev/null
+++ b/ exercises/HelloWorldMain/target/classes/liquibase_file.xml
@@ -0,0 +1,31 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/ exercises/HelloWorldMain/target/classes/log4j.properties b/ exercises/HelloWorldMain/target/classes/log4j.properties
new file mode 100644
index 0000000..7b64d41
--- /dev/null
+++ b/ exercises/HelloWorldMain/target/classes/log4j.properties
@@ -0,0 +1,17 @@
+log4j.rootLogger=info, stdout, R
+
+log4j.appender.stdout=org.apache.log4j.ConsoleAppender
+log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
+
+# Pattern to output the caller's file name and line number.
+log4j.appender.stdout.layout.ConversionPattern=%5p [%t] (%F:%L) - %m%n
+
+log4j.appender.R=org.apache.log4j.RollingFileAppender
+log4j.appender.R.File=logs.log
+
+log4j.appender.R.MaxFileSize=100KB
+# Keep one backup file
+log4j.appender.R.MaxBackupIndex=1
+
+log4j.appender.R.layout=org.apache.log4j.PatternLayout
+log4j.appender.R.layout.ConversionPattern=%p %t %c - %m%n
diff --git a/ exercises/HelloWorldMain/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst b/ exercises/HelloWorldMain/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst
new file mode 100644
index 0000000..f77e005
--- /dev/null
+++ b/ exercises/HelloWorldMain/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst
@@ -0,0 +1 @@
+ro\teamnet\hello\HelloWorld.class
diff --git a/ exercises/HelloWorldMain/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst b/ exercises/HelloWorldMain/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst
new file mode 100644
index 0000000..2507747
--- /dev/null
+++ b/ exercises/HelloWorldMain/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst
@@ -0,0 +1 @@
+C:\Users\Buli\Documents\GitHub\Java\ exercises\HelloWorldMain\src\main\java\ro\teamnet\hello\HelloWorld.java
diff --git a/ exercises/teamnet/.idea/.name b/ exercises/teamnet/.idea/.name
new file mode 100644
index 0000000..d54a42c
--- /dev/null
+++ b/ exercises/teamnet/.idea/.name
@@ -0,0 +1 @@
+teamnet
\ No newline at end of file
diff --git a/ exercises/teamnet/.idea/compiler.xml b/ exercises/teamnet/.idea/compiler.xml
new file mode 100644
index 0000000..217af47
--- /dev/null
+++ b/ exercises/teamnet/.idea/compiler.xml
@@ -0,0 +1,23 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/ exercises/teamnet/.idea/copyright/profiles_settings.xml b/ exercises/teamnet/.idea/copyright/profiles_settings.xml
new file mode 100644
index 0000000..e7bedf3
--- /dev/null
+++ b/ exercises/teamnet/.idea/copyright/profiles_settings.xml
@@ -0,0 +1,3 @@
+
+
+
\ No newline at end of file
diff --git a/ exercises/teamnet/.idea/encodings.xml b/ exercises/teamnet/.idea/encodings.xml
new file mode 100644
index 0000000..e206d70
--- /dev/null
+++ b/ exercises/teamnet/.idea/encodings.xml
@@ -0,0 +1,5 @@
+
+
+
+
+
diff --git a/ exercises/teamnet/.idea/misc.xml b/ exercises/teamnet/.idea/misc.xml
new file mode 100644
index 0000000..d53afa3
--- /dev/null
+++ b/ exercises/teamnet/.idea/misc.xml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
+
+
+
+
diff --git a/ exercises/teamnet/.idea/modules.xml b/ exercises/teamnet/.idea/modules.xml
new file mode 100644
index 0000000..58a0721
--- /dev/null
+++ b/ exercises/teamnet/.idea/modules.xml
@@ -0,0 +1,9 @@
+
+
+
+
+
+
+
+
+
diff --git a/ exercises/teamnet/.idea/scopes/scope_settings.xml b/ exercises/teamnet/.idea/scopes/scope_settings.xml
new file mode 100644
index 0000000..922003b
--- /dev/null
+++ b/ exercises/teamnet/.idea/scopes/scope_settings.xml
@@ -0,0 +1,5 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/ exercises/teamnet/.idea/uiDesigner.xml b/ exercises/teamnet/.idea/uiDesigner.xml
new file mode 100644
index 0000000..3b00020
--- /dev/null
+++ b/ exercises/teamnet/.idea/uiDesigner.xml
@@ -0,0 +1,125 @@
+
+
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+
+
+
+ -
+
+
+
+
+
+ -
+
+
+
+
+
+ -
+
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+
+
+ -
+
+
+ -
+
+
+
+
+
+
diff --git a/ exercises/teamnet/.idea/vcs.xml b/ exercises/teamnet/.idea/vcs.xml
new file mode 100644
index 0000000..def6a6a
--- /dev/null
+++ b/ exercises/teamnet/.idea/vcs.xml
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
diff --git a/ exercises/teamnet/.idea/workspace.xml b/ exercises/teamnet/.idea/workspace.xml
new file mode 100644
index 0000000..5ba703e
--- /dev/null
+++ b/ exercises/teamnet/.idea/workspace.xml
@@ -0,0 +1,1175 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ localhost
+ 5050
+
+
+
+
+
+
+
+
+
+ 1414413942194
+ 1414413942194
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ No facets are configured
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1.7
+
+
+
+
+
+
+
+
+
+
+
+ teamnet
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/ exercises/teamnet/USPresident.data b/ exercises/teamnet/USPresident.data
new file mode 100644
index 0000000..98cc1d1
Binary files /dev/null and b/ exercises/teamnet/USPresident.data differ
diff --git a/ exercises/teamnet/out/production/teamnet/ro/teamnet/zerotohero/canvas/Canvas.class b/ exercises/teamnet/out/production/teamnet/ro/teamnet/zerotohero/canvas/Canvas.class
new file mode 100644
index 0000000..c367561
Binary files /dev/null and b/ exercises/teamnet/out/production/teamnet/ro/teamnet/zerotohero/canvas/Canvas.class differ
diff --git a/ exercises/teamnet/out/production/teamnet/ro/teamnet/zerotohero/gc/DemoObject.class b/ exercises/teamnet/out/production/teamnet/ro/teamnet/zerotohero/gc/DemoObject.class
new file mode 100644
index 0000000..f701068
Binary files /dev/null and b/ exercises/teamnet/out/production/teamnet/ro/teamnet/zerotohero/gc/DemoObject.class differ
diff --git a/ exercises/teamnet/out/production/teamnet/ro/teamnet/zerotohero/gc/GCExample.class b/ exercises/teamnet/out/production/teamnet/ro/teamnet/zerotohero/gc/GCExample.class
new file mode 100644
index 0000000..5b8fed6
Binary files /dev/null and b/ exercises/teamnet/out/production/teamnet/ro/teamnet/zerotohero/gc/GCExample.class differ
diff --git a/ exercises/teamnet/out/production/teamnet/ro/teamnet/zerotohero/oop/graphicshape/AbstractShape.class b/ exercises/teamnet/out/production/teamnet/ro/teamnet/zerotohero/oop/graphicshape/AbstractShape.class
new file mode 100644
index 0000000..36c681b
Binary files /dev/null and b/ exercises/teamnet/out/production/teamnet/ro/teamnet/zerotohero/oop/graphicshape/AbstractShape.class differ
diff --git a/ exercises/teamnet/out/production/teamnet/ro/teamnet/zerotohero/oop/graphicshape/Circle.class b/ exercises/teamnet/out/production/teamnet/ro/teamnet/zerotohero/oop/graphicshape/Circle.class
new file mode 100644
index 0000000..6f14457
Binary files /dev/null and b/ exercises/teamnet/out/production/teamnet/ro/teamnet/zerotohero/oop/graphicshape/Circle.class differ
diff --git a/ exercises/teamnet/out/production/teamnet/ro/teamnet/zerotohero/oop/graphicshape/Circles.class b/ exercises/teamnet/out/production/teamnet/ro/teamnet/zerotohero/oop/graphicshape/Circles.class
new file mode 100644
index 0000000..ff60252
Binary files /dev/null and b/ exercises/teamnet/out/production/teamnet/ro/teamnet/zerotohero/oop/graphicshape/Circles.class differ
diff --git a/ exercises/teamnet/out/production/teamnet/ro/teamnet/zerotohero/oop/graphicshape/ImmutableClass.class b/ exercises/teamnet/out/production/teamnet/ro/teamnet/zerotohero/oop/graphicshape/ImmutableClass.class
new file mode 100644
index 0000000..c00a776
Binary files /dev/null and b/ exercises/teamnet/out/production/teamnet/ro/teamnet/zerotohero/oop/graphicshape/ImmutableClass.class differ
diff --git a/ exercises/teamnet/out/production/teamnet/ro/teamnet/zerotohero/oop/graphicshape/Point.class b/ exercises/teamnet/out/production/teamnet/ro/teamnet/zerotohero/oop/graphicshape/Point.class
new file mode 100644
index 0000000..c432f3c
Binary files /dev/null and b/ exercises/teamnet/out/production/teamnet/ro/teamnet/zerotohero/oop/graphicshape/Point.class differ
diff --git a/ exercises/teamnet/out/production/teamnet/ro/teamnet/zerotohero/oop/graphicshape/Point3D.class b/ exercises/teamnet/out/production/teamnet/ro/teamnet/zerotohero/oop/graphicshape/Point3D.class
new file mode 100644
index 0000000..de80bd8
Binary files /dev/null and b/ exercises/teamnet/out/production/teamnet/ro/teamnet/zerotohero/oop/graphicshape/Point3D.class differ
diff --git a/ exercises/teamnet/out/production/teamnet/ro/teamnet/zerotohero/oop/graphicshape/Shape.class b/ exercises/teamnet/out/production/teamnet/ro/teamnet/zerotohero/oop/graphicshape/Shape.class
new file mode 100644
index 0000000..0293974
Binary files /dev/null and b/ exercises/teamnet/out/production/teamnet/ro/teamnet/zerotohero/oop/graphicshape/Shape.class differ
diff --git a/ exercises/teamnet/out/production/teamnet/ro/teamnet/zerotohero/oop/graphicshape/ShapeBehaviour.class b/ exercises/teamnet/out/production/teamnet/ro/teamnet/zerotohero/oop/graphicshape/ShapeBehaviour.class
new file mode 100644
index 0000000..b878780
Binary files /dev/null and b/ exercises/teamnet/out/production/teamnet/ro/teamnet/zerotohero/oop/graphicshape/ShapeBehaviour.class differ
diff --git a/ exercises/teamnet/out/production/teamnet/ro/teamnet/zerotohero/oop/graphicshape/Square.class b/ exercises/teamnet/out/production/teamnet/ro/teamnet/zerotohero/oop/graphicshape/Square.class
new file mode 100644
index 0000000..244227a
Binary files /dev/null and b/ exercises/teamnet/out/production/teamnet/ro/teamnet/zerotohero/oop/graphicshape/Square.class differ
diff --git a/ exercises/teamnet/out/production/teamnet/ro/teamnet/zerotohero/oop/runapp/RunApp.class b/ exercises/teamnet/out/production/teamnet/ro/teamnet/zerotohero/oop/runapp/RunApp.class
new file mode 100644
index 0000000..bae7d90
Binary files /dev/null and b/ exercises/teamnet/out/production/teamnet/ro/teamnet/zerotohero/oop/runapp/RunApp.class differ
diff --git a/ exercises/teamnet/out/production/teamnet/ro/teamnet/zerotohero/reflection/api/Column.class b/ exercises/teamnet/out/production/teamnet/ro/teamnet/zerotohero/reflection/api/Column.class
new file mode 100644
index 0000000..0495919
Binary files /dev/null and b/ exercises/teamnet/out/production/teamnet/ro/teamnet/zerotohero/reflection/api/Column.class differ
diff --git a/ exercises/teamnet/out/production/teamnet/ro/teamnet/zerotohero/reflection/api/DBManager.class b/ exercises/teamnet/out/production/teamnet/ro/teamnet/zerotohero/reflection/api/DBManager.class
new file mode 100644
index 0000000..29a68d6
Binary files /dev/null and b/ exercises/teamnet/out/production/teamnet/ro/teamnet/zerotohero/reflection/api/DBManager.class differ
diff --git a/ exercises/teamnet/out/production/teamnet/ro/teamnet/zerotohero/reflection/api/Table.class b/ exercises/teamnet/out/production/teamnet/ro/teamnet/zerotohero/reflection/api/Table.class
new file mode 100644
index 0000000..6826bac
Binary files /dev/null and b/ exercises/teamnet/out/production/teamnet/ro/teamnet/zerotohero/reflection/api/Table.class differ
diff --git a/ exercises/teamnet/out/production/teamnet/ro/teamnet/zerotohero/reflection/model/Employee.class b/ exercises/teamnet/out/production/teamnet/ro/teamnet/zerotohero/reflection/model/Employee.class
new file mode 100644
index 0000000..45d6b97
Binary files /dev/null and b/ exercises/teamnet/out/production/teamnet/ro/teamnet/zerotohero/reflection/model/Employee.class differ
diff --git a/ exercises/teamnet/out/production/teamnet/ro/teamnet/zerotohero/serializare/Student.class b/ exercises/teamnet/out/production/teamnet/ro/teamnet/zerotohero/serializare/Student.class
new file mode 100644
index 0000000..c707277
Binary files /dev/null and b/ exercises/teamnet/out/production/teamnet/ro/teamnet/zerotohero/serializare/Student.class differ
diff --git a/ exercises/teamnet/out/production/teamnet/ro/teamnet/zerotohero/serializare/TestStudent.class b/ exercises/teamnet/out/production/teamnet/ro/teamnet/zerotohero/serializare/TestStudent.class
new file mode 100644
index 0000000..c6a7005
Binary files /dev/null and b/ exercises/teamnet/out/production/teamnet/ro/teamnet/zerotohero/serializare/TestStudent.class differ
diff --git a/ exercises/teamnet/out/production/teamnet/ro/teamnet/zerotohero/serializare/TransientSerialization.class b/ exercises/teamnet/out/production/teamnet/ro/teamnet/zerotohero/serializare/TransientSerialization.class
new file mode 100644
index 0000000..889bf20
Binary files /dev/null and b/ exercises/teamnet/out/production/teamnet/ro/teamnet/zerotohero/serializare/TransientSerialization.class differ
diff --git a/ exercises/teamnet/out/production/teamnet/ro/teamnet/zerotohero/serializare/USPresident.class b/ exercises/teamnet/out/production/teamnet/ro/teamnet/zerotohero/serializare/USPresident.class
new file mode 100644
index 0000000..904ec27
Binary files /dev/null and b/ exercises/teamnet/out/production/teamnet/ro/teamnet/zerotohero/serializare/USPresident.class differ
diff --git a/ exercises/teamnet/out/production/teamnet/ro/teamnet/zerotohero/threads/counter/Counter.class b/ exercises/teamnet/out/production/teamnet/ro/teamnet/zerotohero/threads/counter/Counter.class
new file mode 100644
index 0000000..9603577
Binary files /dev/null and b/ exercises/teamnet/out/production/teamnet/ro/teamnet/zerotohero/threads/counter/Counter.class differ
diff --git a/ exercises/teamnet/out/production/teamnet/ro/teamnet/zerotohero/threads/counter/SyncronizeCounter$1.class b/ exercises/teamnet/out/production/teamnet/ro/teamnet/zerotohero/threads/counter/SyncronizeCounter$1.class
new file mode 100644
index 0000000..dc91b58
Binary files /dev/null and b/ exercises/teamnet/out/production/teamnet/ro/teamnet/zerotohero/threads/counter/SyncronizeCounter$1.class differ
diff --git a/ exercises/teamnet/out/production/teamnet/ro/teamnet/zerotohero/threads/counter/SyncronizeCounter$2.class b/ exercises/teamnet/out/production/teamnet/ro/teamnet/zerotohero/threads/counter/SyncronizeCounter$2.class
new file mode 100644
index 0000000..fa7fda0
Binary files /dev/null and b/ exercises/teamnet/out/production/teamnet/ro/teamnet/zerotohero/threads/counter/SyncronizeCounter$2.class differ
diff --git a/ exercises/teamnet/out/production/teamnet/ro/teamnet/zerotohero/threads/counter/SyncronizeCounter.class b/ exercises/teamnet/out/production/teamnet/ro/teamnet/zerotohero/threads/counter/SyncronizeCounter.class
new file mode 100644
index 0000000..ae83139
Binary files /dev/null and b/ exercises/teamnet/out/production/teamnet/ro/teamnet/zerotohero/threads/counter/SyncronizeCounter.class differ
diff --git a/ exercises/teamnet/out/production/teamnet/ro/teamnet/zerotohero/threads/thread_creation/ClassRunnable.class b/ exercises/teamnet/out/production/teamnet/ro/teamnet/zerotohero/threads/thread_creation/ClassRunnable.class
new file mode 100644
index 0000000..9d6fd41
Binary files /dev/null and b/ exercises/teamnet/out/production/teamnet/ro/teamnet/zerotohero/threads/thread_creation/ClassRunnable.class differ
diff --git a/ exercises/teamnet/out/production/teamnet/ro/teamnet/zerotohero/threads/thread_creation/ClassThread.class b/ exercises/teamnet/out/production/teamnet/ro/teamnet/zerotohero/threads/thread_creation/ClassThread.class
new file mode 100644
index 0000000..5164f9b
Binary files /dev/null and b/ exercises/teamnet/out/production/teamnet/ro/teamnet/zerotohero/threads/thread_creation/ClassThread.class differ
diff --git a/ exercises/teamnet/out/production/teamnet/ro/teamnet/zerotohero/threads/thread_creation/ThreadTester.class b/ exercises/teamnet/out/production/teamnet/ro/teamnet/zerotohero/threads/thread_creation/ThreadTester.class
new file mode 100644
index 0000000..84abfa9
Binary files /dev/null and b/ exercises/teamnet/out/production/teamnet/ro/teamnet/zerotohero/threads/thread_creation/ThreadTester.class differ
diff --git a/ exercises/teamnet/src/main/java/ro/teamnet/zerotohero/canvas/Canvas.java b/ exercises/teamnet/src/main/java/ro/teamnet/zerotohero/canvas/Canvas.java
new file mode 100644
index 0000000..46aa8a3
--- /dev/null
+++ b/ exercises/teamnet/src/main/java/ro/teamnet/zerotohero/canvas/Canvas.java
@@ -0,0 +1,14 @@
+package ro.teamnet.zerotohero.canvas;
+
+import ro.teamnet.zerotohero.oop.graphicshape.Circle;
+
+/**
+ * Created by Buli on 27.10.2014.
+ */
+public class Canvas {
+
+ public double getArea(){
+ Circle myCircle = new Circle();
+ return myCircle.area();
+ }
+}
diff --git a/ exercises/teamnet/src/main/java/ro/teamnet/zerotohero/gc/DemoObject.java b/ exercises/teamnet/src/main/java/ro/teamnet/zerotohero/gc/DemoObject.java
new file mode 100644
index 0000000..ef959d4
--- /dev/null
+++ b/ exercises/teamnet/src/main/java/ro/teamnet/zerotohero/gc/DemoObject.java
@@ -0,0 +1,38 @@
+package ro.teamnet.zerotohero.gc;
+
+import java.lang.management.GarbageCollectorMXBean;
+
+/**
+ * Created by Buli on 27.10.2014.
+ */
+public class DemoObject {
+
+ private static final int bufferSize = 100000;
+ private String temp;
+ private String objectRef;
+ private static int count = 0;
+
+ public DemoObject() {
+ this.objectRef = this.toString();
+ StringBuilder s = new StringBuilder();
+
+ for(int i=0; i5){
+ System.gc();
+ }
+
+ }
+
+ @Override
+ public void finalize()throws Throwable{
+ count --;
+ System.out.println(count);
+ }
+}
diff --git a/ exercises/teamnet/src/main/java/ro/teamnet/zerotohero/gc/GCExample.java b/ exercises/teamnet/src/main/java/ro/teamnet/zerotohero/gc/GCExample.java
new file mode 100644
index 0000000..da11761
--- /dev/null
+++ b/ exercises/teamnet/src/main/java/ro/teamnet/zerotohero/gc/GCExample.java
@@ -0,0 +1,20 @@
+package ro.teamnet.zerotohero.gc;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Created by Buli on 27.10.2014.
+ */
+public class GCExample {
+
+ public static void main(String[] args) {
+ List demoObjects = new ArrayList();
+ while(true) {
+ new DemoObject();
+ demoObjects.add(new DemoObject());
+ }
+ }
+
+
+}
diff --git a/ exercises/teamnet/src/main/java/ro/teamnet/zerotohero/oop/graphicshape/AbstractShape.java b/ exercises/teamnet/src/main/java/ro/teamnet/zerotohero/oop/graphicshape/AbstractShape.java
new file mode 100644
index 0000000..1c43135
--- /dev/null
+++ b/ exercises/teamnet/src/main/java/ro/teamnet/zerotohero/oop/graphicshape/AbstractShape.java
@@ -0,0 +1,14 @@
+package ro.teamnet.zerotohero.oop.graphicshape;
+
+/**
+ * Created by Buli on 27.10.2014.
+ */
+public abstract class AbstractShape {
+
+ private double value = 21;
+
+ public double area(){
+ return value;
+ };
+
+}
diff --git a/ exercises/teamnet/src/main/java/ro/teamnet/zerotohero/oop/graphicshape/Circle.java b/ exercises/teamnet/src/main/java/ro/teamnet/zerotohero/oop/graphicshape/Circle.java
new file mode 100644
index 0000000..a784822
--- /dev/null
+++ b/ exercises/teamnet/src/main/java/ro/teamnet/zerotohero/oop/graphicshape/Circle.java
@@ -0,0 +1,54 @@
+package ro.teamnet.zerotohero.oop.graphicshape;
+
+/**
+ * Created by Buli on 27.10.2014.
+ */
+public class Circle extends Shape{
+
+ private int xPos,yPos, radius;
+
+ public Circle() {
+ this.xPos = 41;
+ this.yPos = 30;
+ this.radius = 2;
+ }
+
+ public Circle(int xPos) {
+ this.xPos = xPos;
+ }
+
+ public Circle(int xPos, int yPos) {
+ this.xPos = xPos;
+ this.yPos = yPos;
+ }
+
+ public Circle(int xPos, int yPos, int radius) {
+ this.xPos = xPos;
+ this.radius = radius;
+ this.yPos = yPos;
+ }
+
+ @Override
+ public double area(){
+ return Math.PI * radius*radius;
+ }
+
+ @Override
+ public String toString(){
+ return "center = ("+ xPos + "," + yPos + ") and radius =" + radius;
+ }
+
+ public void fillColour(){
+ System.out.println(super.color);
+ }
+
+ public void fillColour(int param){
+ super.setColor(param);
+ System.out.println("The circle color is now " + param);
+ }
+
+ public void fillColour(float param){
+ super.setSaturation(param);
+ System.out.println("The saturation is now " + param);
+ }
+}
diff --git a/ exercises/teamnet/src/main/java/ro/teamnet/zerotohero/oop/graphicshape/Circles.java b/ exercises/teamnet/src/main/java/ro/teamnet/zerotohero/oop/graphicshape/Circles.java
new file mode 100644
index 0000000..e973ce3
--- /dev/null
+++ b/ exercises/teamnet/src/main/java/ro/teamnet/zerotohero/oop/graphicshape/Circles.java
@@ -0,0 +1,23 @@
+package ro.teamnet.zerotohero.oop.graphicshape;
+
+/**
+ * Created by Buli on 27.10.2014.
+ */
+public class Circles {
+
+ public Circles() {
+ }
+
+ public double getAreaPub(){
+ Circle circle1 = new Circle();
+ return circle1.area();
+ }
+
+ public void getAreaDef(){
+ Circle myCircle = new Circle();
+ myCircle.fillColour();
+ myCircle.fillColour(2);
+ myCircle.fillColour((float) 21.2);
+ }
+
+}
diff --git a/ exercises/teamnet/src/main/java/ro/teamnet/zerotohero/oop/graphicshape/ImmutableClass.java b/ exercises/teamnet/src/main/java/ro/teamnet/zerotohero/oop/graphicshape/ImmutableClass.java
new file mode 100644
index 0000000..a66cc1c
--- /dev/null
+++ b/ exercises/teamnet/src/main/java/ro/teamnet/zerotohero/oop/graphicshape/ImmutableClass.java
@@ -0,0 +1,27 @@
+package ro.teamnet.zerotohero.oop.graphicshape;
+
+/**
+ * Created by Buli on 27.10.2014.
+ */
+public final class ImmutableClass {
+
+ private final int field;
+ private final float field2;
+
+ private ImmutableClass(int field, float field2) {
+ this.field = field;
+ this.field2 = field2;
+ }
+
+ public static ImmutableClass createNewInstance(int fld, float fld2){
+ return new ImmutableClass(fld,fld2);
+ }
+
+ public int getField() {
+ return field;
+ }
+
+ public float getField2() {
+ return field2;
+ }
+}
diff --git a/ exercises/teamnet/src/main/java/ro/teamnet/zerotohero/oop/graphicshape/MyException.java b/ exercises/teamnet/src/main/java/ro/teamnet/zerotohero/oop/graphicshape/MyException.java
new file mode 100644
index 0000000..af6c7cf
--- /dev/null
+++ b/ exercises/teamnet/src/main/java/ro/teamnet/zerotohero/oop/graphicshape/MyException.java
@@ -0,0 +1,7 @@
+package ro.teamnet.zerotohero.oop.graphicshape;
+
+/**
+ * Created by Buli on 28.10.2014.
+ */
+public class MyException {
+}
diff --git a/ exercises/teamnet/src/main/java/ro/teamnet/zerotohero/oop/graphicshape/Point.java b/ exercises/teamnet/src/main/java/ro/teamnet/zerotohero/oop/graphicshape/Point.java
new file mode 100644
index 0000000..94e1b21
--- /dev/null
+++ b/ exercises/teamnet/src/main/java/ro/teamnet/zerotohero/oop/graphicshape/Point.java
@@ -0,0 +1,29 @@
+package ro.teamnet.zerotohero.oop.graphicshape;
+
+/**
+ * Created by Buli on 27.10.2014.
+ */
+public class Point {
+
+ private int xPos, yPos;
+
+ public Point(int xPos, int yPos) {
+ this.xPos = xPos;
+ this.yPos = yPos;
+ }
+
+ @Override
+ public boolean equals(Object other){
+ if(other == null){
+ return false;
+ }
+
+ if(other instanceof Point){
+ Point anotherPoint = (Point) other;
+ if((xPos == anotherPoint.xPos) && (yPos == anotherPoint.yPos) )
+ return true;
+ }
+
+ return false;
+ }
+}
diff --git a/ exercises/teamnet/src/main/java/ro/teamnet/zerotohero/oop/graphicshape/Point3D.java b/ exercises/teamnet/src/main/java/ro/teamnet/zerotohero/oop/graphicshape/Point3D.java
new file mode 100644
index 0000000..6b2f5af
--- /dev/null
+++ b/ exercises/teamnet/src/main/java/ro/teamnet/zerotohero/oop/graphicshape/Point3D.java
@@ -0,0 +1,14 @@
+package ro.teamnet.zerotohero.oop.graphicshape;
+
+/**
+ * Created by Buli on 27.10.2014.
+ */
+public class Point3D extends Point {
+
+ private int zPos;
+
+ public Point3D(int x, int y, int zPos){
+ super(x,y);
+ this.zPos = zPos;
+ }
+}
diff --git a/ exercises/teamnet/src/main/java/ro/teamnet/zerotohero/oop/graphicshape/Shape.java b/ exercises/teamnet/src/main/java/ro/teamnet/zerotohero/oop/graphicshape/Shape.java
new file mode 100644
index 0000000..fb6ffaa
--- /dev/null
+++ b/ exercises/teamnet/src/main/java/ro/teamnet/zerotohero/oop/graphicshape/Shape.java
@@ -0,0 +1,24 @@
+package ro.teamnet.zerotohero.oop.graphicshape;
+
+/**
+ * Created by Buli on 27.10.2014.
+ */
+public class Shape extends AbstractShape implements ShapeBehaviour {
+ protected int color;
+ protected float saturation;
+
+
+ public double area(){
+ double value = 0;
+ System.out.println("Area");
+ return value;
+ }
+
+ public void setColor(int color) {
+ this.color = color;
+ }
+
+ public void setSaturation(float saturation) {
+ this.saturation = saturation;
+ }
+}
diff --git a/ exercises/teamnet/src/main/java/ro/teamnet/zerotohero/oop/graphicshape/ShapeBehaviour.java b/ exercises/teamnet/src/main/java/ro/teamnet/zerotohero/oop/graphicshape/ShapeBehaviour.java
new file mode 100644
index 0000000..4ef73a5
--- /dev/null
+++ b/ exercises/teamnet/src/main/java/ro/teamnet/zerotohero/oop/graphicshape/ShapeBehaviour.java
@@ -0,0 +1,10 @@
+package ro.teamnet.zerotohero.oop.graphicshape;
+
+/**
+ * Created by Buli on 27.10.2014.
+ */
+public interface ShapeBehaviour {
+
+ public double area();
+
+}
diff --git a/ exercises/teamnet/src/main/java/ro/teamnet/zerotohero/oop/graphicshape/Square.java b/ exercises/teamnet/src/main/java/ro/teamnet/zerotohero/oop/graphicshape/Square.java
new file mode 100644
index 0000000..d9aeb0b
--- /dev/null
+++ b/ exercises/teamnet/src/main/java/ro/teamnet/zerotohero/oop/graphicshape/Square.java
@@ -0,0 +1,17 @@
+package ro.teamnet.zerotohero.oop.graphicshape;
+
+/**
+ * Created by Buli on 27.10.2014.
+ */
+public class Square extends Shape{
+
+ private int side;
+
+ public Square(int side) {
+ this.side = side;
+ }
+
+ public double area(){
+ return side*side;
+ }
+}
diff --git a/ exercises/teamnet/src/main/java/ro/teamnet/zerotohero/oop/runapp/RunApp.java b/ exercises/teamnet/src/main/java/ro/teamnet/zerotohero/oop/runapp/RunApp.java
new file mode 100644
index 0000000..731748a
--- /dev/null
+++ b/ exercises/teamnet/src/main/java/ro/teamnet/zerotohero/oop/runapp/RunApp.java
@@ -0,0 +1,42 @@
+package ro.teamnet.zerotohero.oop.runapp;
+
+import ro.teamnet.zerotohero.oop.graphicshape.*;
+import ro.teamnet.zerotohero.canvas.Canvas;
+
+/**
+ * Created by Buli on 27.10.2014.
+ */
+public class RunApp {
+
+ public static void main(String[] args){
+ Circles myCircles = new Circles();
+ System.out.println("The default circle area is " + myCircles.getAreaPub());
+
+ System.out.print("getAreaDef result: ");
+ myCircles.getAreaDef();
+
+ Canvas myCanvas = new Canvas();
+ //myCanvas.getArea();
+
+ Shape myShape = new Circle(10);
+ System.out.println("New circle area: " + myShape.area());
+
+ ShapeBehaviour myShapeB = new Square(10);
+ System.out.println("New square area: " + myShapeB.area());
+
+ Object p1 = new Point(10, 20);
+ Object p2 = new Point(50, 100);
+ Object p3 = new Point(10, 20);
+
+ System.out.println("p1 equals p2 is " + p1.equals(p2));
+ System.out.println("p1 equals p3 is " + p1.equals(p3));
+
+ //ImmutableClass newObject = new ImmutableClass(2,2.3);
+ ImmutableClass newObj = ImmutableClass.createNewInstance(2,(float) 2.3);
+ System.out.println("Field immutable: " + newObj.getField());
+ System.out.println("Field2 immutable: " + newObj.getField2());
+
+
+ }
+
+}
diff --git a/ exercises/teamnet/src/main/java/ro/teamnet/zerotohero/reflection/api/Column.java b/ exercises/teamnet/src/main/java/ro/teamnet/zerotohero/reflection/api/Column.java
new file mode 100644
index 0000000..b208b99
--- /dev/null
+++ b/ exercises/teamnet/src/main/java/ro/teamnet/zerotohero/reflection/api/Column.java
@@ -0,0 +1,16 @@
+package ro.teamnet.zerotohero.reflection.api;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Created by Buli on 28.10.2014.
+ */
+
+@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.FIELD)
+public @interface Column {
+ String columnName();
+}
diff --git a/ exercises/teamnet/src/main/java/ro/teamnet/zerotohero/reflection/api/DBManager.java b/ exercises/teamnet/src/main/java/ro/teamnet/zerotohero/reflection/api/DBManager.java
new file mode 100644
index 0000000..09bd6c5
--- /dev/null
+++ b/ exercises/teamnet/src/main/java/ro/teamnet/zerotohero/reflection/api/DBManager.java
@@ -0,0 +1,43 @@
+package ro.teamnet.zerotohero.reflection.api;
+
+import ro.teamnet.zerotohero.reflection.model.Employee;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Field;
+
+/**
+ * Created by Buli on 28.10.2014.
+ */
+public class DBManager {
+
+ public static void insert(Object o){
+ if(o.getClass().getAnnotation(Table.class).tableName() == null && o.getClass().getAnnotation(Column.class).columnName() == null)
+ throw new IllegalArgumentException();
+
+ Table table = o.getClass().getAnnotation(Table.class);
+ System.out.println("Table name: " + table.tableName());
+
+ Field[] columns = o.getClass().getFields();
+ for(Field column:columns){
+
+ Column c = (Column) column.getAnnotation(Column.class);
+ System.out.println(c.columnName());
+
+ try {
+ System.out.println(column.get(o));
+ } catch (IllegalAccessException e) {
+ e.printStackTrace();
+ }
+ }
+
+
+ }
+
+ public static void main(String[] Args){
+ Employee emp = new Employee();
+ emp.name = "Ion";
+ emp.job = "CEO";
+
+ insert(emp);
+ }
+}
diff --git a/ exercises/teamnet/src/main/java/ro/teamnet/zerotohero/reflection/api/Table.java b/ exercises/teamnet/src/main/java/ro/teamnet/zerotohero/reflection/api/Table.java
new file mode 100644
index 0000000..c023add
--- /dev/null
+++ b/ exercises/teamnet/src/main/java/ro/teamnet/zerotohero/reflection/api/Table.java
@@ -0,0 +1,16 @@
+package ro.teamnet.zerotohero.reflection.api;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Created by Buli on 28.10.2014.
+ */
+
+@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.TYPE)
+public @interface Table {
+ String tableName();
+}
diff --git a/ exercises/teamnet/src/main/java/ro/teamnet/zerotohero/reflection/model/Employee.java b/ exercises/teamnet/src/main/java/ro/teamnet/zerotohero/reflection/model/Employee.java
new file mode 100644
index 0000000..9fa66eb
--- /dev/null
+++ b/ exercises/teamnet/src/main/java/ro/teamnet/zerotohero/reflection/model/Employee.java
@@ -0,0 +1,19 @@
+package ro.teamnet.zerotohero.reflection.model;
+
+import ro.teamnet.zerotohero.reflection.api.Column;
+import ro.teamnet.zerotohero.reflection.api.Table;
+
+/**
+ * Created by Buli on 28.10.2014.
+ */
+
+@Table(tableName = "EMP")
+public class Employee {
+
+ @Column(columnName = "NAME")
+ public String name;
+
+ @Column(columnName = "JOB")
+ public String job;
+
+}
diff --git a/ exercises/teamnet/src/main/java/ro/teamnet/zerotohero/serializare/Student.java b/ exercises/teamnet/src/main/java/ro/teamnet/zerotohero/serializare/Student.java
new file mode 100644
index 0000000..98578aa
--- /dev/null
+++ b/ exercises/teamnet/src/main/java/ro/teamnet/zerotohero/serializare/Student.java
@@ -0,0 +1,24 @@
+package ro.teamnet.zerotohero.serializare;
+
+import java.io.Serializable;
+
+/**
+ * Created by Buli on 28.10.2014.
+ */
+public class Student implements Serializable{
+
+ int id;
+ String firstName;
+ String lastName;
+
+ public Student(int id, String firstName, String lastName) {
+ this.id = id;
+ this.firstName = firstName;
+ this.lastName = lastName;
+ }
+
+ @Override
+ public String toString(){
+ return "Student id " + id + ", First name " + firstName + ", Last name " + lastName;
+ }
+}
diff --git a/ exercises/teamnet/src/main/java/ro/teamnet/zerotohero/serializare/TestStudent.java b/ exercises/teamnet/src/main/java/ro/teamnet/zerotohero/serializare/TestStudent.java
new file mode 100644
index 0000000..677fc27
--- /dev/null
+++ b/ exercises/teamnet/src/main/java/ro/teamnet/zerotohero/serializare/TestStudent.java
@@ -0,0 +1,43 @@
+package ro.teamnet.zerotohero.serializare;
+
+import java.io.*;
+
+/**
+ * Created by Buli on 28.10.2014.
+ */
+public class TestStudent {
+
+ public static void main(String[] Args){
+
+ Student newStudent = new Student(1,"Vlad", "Bulimac");
+
+ try(ObjectOutputStream os = new ObjectOutputStream(new FileOutputStream("student.data"))){
+ os.writeObject(newStudent);
+ }
+ catch(FileNotFoundException fnfe){
+ System.err.println("cannot create a file with the given file name ");
+ }
+ catch(IOException ioe){
+ System.err.println("IO Error");
+ }
+
+ try(ObjectInputStream ois = new ObjectInputStream(new FileInputStream("student.data"))){
+ Object obj = ois.readObject();
+ if(obj != null && obj instanceof Student) {
+ Student newStud = (Student) obj;
+ System.out.println(newStud);
+ }
+ }
+ catch(FileNotFoundException fnfe){
+ System.err.println("cannot read a file with the given file name ");
+ }
+ catch(ClassNotFoundException cnfe){
+ System.err.println("cannot recognize the class of the object - is the file corrupted?");
+ }
+ catch(IOException ioe){
+ System.err.println("an I/O error occurred while processing the file");
+ }
+
+ }
+
+}
diff --git a/ exercises/teamnet/src/main/java/ro/teamnet/zerotohero/serializare/TransientSerialization.java b/ exercises/teamnet/src/main/java/ro/teamnet/zerotohero/serializare/TransientSerialization.java
new file mode 100644
index 0000000..e499b28
--- /dev/null
+++ b/ exercises/teamnet/src/main/java/ro/teamnet/zerotohero/serializare/TransientSerialization.java
@@ -0,0 +1,42 @@
+package ro.teamnet.zerotohero.serializare;
+
+import java.io.*;
+
+/**
+ * Created by Buli on 28.10.2014.
+ */
+public class TransientSerialization {
+
+ public static void main(String []args) {
+
+ USPresident usPresident = new USPresident("Barack Obama", "2009 to --", "56th term");
+ System.out.println(usPresident);
+ //Serialize the object
+
+ try (ObjectOutputStream oos = new ObjectOutputStream(new
+ FileOutputStream("USPresident.data"))){
+ oos.writeObject(usPresident);
+ }
+ catch(FileNotFoundException fnfe) {
+ System.err.println("cannot create a file with the given file name ");
+ } catch(IOException ioe) {
+ System.err.println("an I/O error occurred while processing the file");
+ } // the ObjectOutputStream will auto-close, so don't have to worry about it
+ //De-serialize the object
+
+ try(ObjectInputStream ois = new ObjectInputStream(new
+ FileInputStream("USPresident.data"))){
+ Object obj = ois.readObject();
+ if(obj != null && obj instanceof USPresident){
+ USPresident presidentOfUS = (USPresident)obj;
+ System.out.println(presidentOfUS);
+ }
+ }catch(FileNotFoundException fnfe) {
+ System.err.println("cannot create a file with the given file name ");
+ } catch(IOException ioe) {
+ System.err.println("an I/O error occurred while processing the file");
+ } catch(ClassNotFoundException cnfe) {
+ System.err.println("cannot recognize the class of the object - is the file corrupted?");
+ }
+ }
+}
diff --git a/ exercises/teamnet/src/main/java/ro/teamnet/zerotohero/serializare/USPresident.java b/ exercises/teamnet/src/main/java/ro/teamnet/zerotohero/serializare/USPresident.java
new file mode 100644
index 0000000..69b36f1
--- /dev/null
+++ b/ exercises/teamnet/src/main/java/ro/teamnet/zerotohero/serializare/USPresident.java
@@ -0,0 +1,25 @@
+package ro.teamnet.zerotohero.serializare;
+
+import java.io.Serializable;
+
+/**
+ * Created by Buli on 28.10.2014.
+ */
+public class USPresident implements Serializable {
+ private static final long serialVersionUID = 1L;
+
+ private String name;
+ private String period;
+ private transient String term;
+
+ @Override
+ public String toString() {
+ return "US President [name=" + name + ", period=" + period + ", term=" + term + "]";
+ }
+ public USPresident(String name, String period, String term) {
+ this.name = name;
+ this.period = period;
+ this.term = term;
+ }
+
+}
diff --git a/ exercises/teamnet/src/main/java/ro/teamnet/zerotohero/threads/counter/Counter.java b/ exercises/teamnet/src/main/java/ro/teamnet/zerotohero/threads/counter/Counter.java
new file mode 100644
index 0000000..4a2ae35
--- /dev/null
+++ b/ exercises/teamnet/src/main/java/ro/teamnet/zerotohero/threads/counter/Counter.java
@@ -0,0 +1,27 @@
+package ro.teamnet.zerotohero.threads.counter;
+
+/**
+ * Created by Buli on 28.10.2014.
+ */
+public class Counter {
+
+ public static long counter = 0;
+
+ public static synchronized void increment(){
+ Counter.counter++;
+ System.out.println("Valoarea counterului este:" + Counter.counter);
+
+ Counter.counter++;
+ System.out.println("Valoarea counterului este:" + Counter.counter);
+
+ Counter.counter++;
+ System.out.println("Valoarea counterului este:" + Counter.counter);
+
+ Counter.counter++;
+ System.out.println("Valoarea counterului este:" + Counter.counter);
+
+ Counter.counter++;
+ System.out.println("Valoarea counterului este:" + Counter.counter);
+ }
+
+}
diff --git a/ exercises/teamnet/src/main/java/ro/teamnet/zerotohero/threads/counter/SyncronizeCounter.java b/ exercises/teamnet/src/main/java/ro/teamnet/zerotohero/threads/counter/SyncronizeCounter.java
new file mode 100644
index 0000000..897d201
--- /dev/null
+++ b/ exercises/teamnet/src/main/java/ro/teamnet/zerotohero/threads/counter/SyncronizeCounter.java
@@ -0,0 +1,35 @@
+package ro.teamnet.zerotohero.threads.counter;
+
+/**
+ * Created by Buli on 28.10.2014.
+ */
+public class SyncronizeCounter {
+
+ public static void main(String[] Args){
+
+ Thread t = new Thread(){
+ @Override
+ public void run(){
+ Counter.increment();
+ Counter.increment();
+ Counter.increment();
+ Counter.increment();
+ }
+ };
+
+ Thread t2 = new Thread(){
+ @Override
+ public void run(){
+
+ Counter.increment();
+ Counter.increment();
+ Counter.increment();
+ Counter.increment();
+ }
+ };
+
+ t.start();
+ t2.start();
+ }
+
+}
diff --git a/ exercises/teamnet/src/main/java/ro/teamnet/zerotohero/threads/counter/WaitThread.java b/ exercises/teamnet/src/main/java/ro/teamnet/zerotohero/threads/counter/WaitThread.java
new file mode 100644
index 0000000..be1f820
--- /dev/null
+++ b/ exercises/teamnet/src/main/java/ro/teamnet/zerotohero/threads/counter/WaitThread.java
@@ -0,0 +1,56 @@
+package ro.teamnet.zerotohero.threads.counter;
+
+/**
+ * Created by Buli on 28.10.2014.
+ */
+public class WaitThread {
+
+ public static void main(String[] Args){
+
+ Thread t = new Thread(){
+ @Override
+ public void run(){
+ Counter.increment();
+ Counter.increment();
+ Counter.increment();
+ Counter.increment();
+ }
+ };
+
+ Thread t2 = new Thread(){
+ @Override
+ public void run(){
+
+ Counter.increment();
+ Counter.increment();
+ Counter.increment();
+ Counter.increment();
+ }
+ };
+
+ t.start();
+
+ try {
+ synchronized (t){
+ t.setName("Waiting 1");
+ t.wait();}
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+
+ t2.start();
+
+
+ System.out.println(t.getName());
+ try {
+ synchronized (t2){
+ t2.setName("Waiting 2");
+ t2.wait();}
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+
+ System.out.println(t2.getName());
+ }
+
+}
diff --git a/ exercises/teamnet/src/main/java/ro/teamnet/zerotohero/threads/thread_creation/ClassRunnable.java b/ exercises/teamnet/src/main/java/ro/teamnet/zerotohero/threads/thread_creation/ClassRunnable.java
new file mode 100644
index 0000000..2ce78c0
--- /dev/null
+++ b/ exercises/teamnet/src/main/java/ro/teamnet/zerotohero/threads/thread_creation/ClassRunnable.java
@@ -0,0 +1,14 @@
+package ro.teamnet.zerotohero.threads.thread_creation;
+
+import ro.teamnet.zerotohero.threads.counter.Counter;
+
+/**
+ * Created by Buli on 28.10.2014.
+ */
+public class ClassRunnable implements Runnable{
+
+ public void run(){
+ System.out.println("Runnable class implemented");
+ }
+
+}
diff --git a/ exercises/teamnet/src/main/java/ro/teamnet/zerotohero/threads/thread_creation/ClassThread.java b/ exercises/teamnet/src/main/java/ro/teamnet/zerotohero/threads/thread_creation/ClassThread.java
new file mode 100644
index 0000000..e69270e
--- /dev/null
+++ b/ exercises/teamnet/src/main/java/ro/teamnet/zerotohero/threads/thread_creation/ClassThread.java
@@ -0,0 +1,15 @@
+package ro.teamnet.zerotohero.threads.thread_creation;
+
+import ro.teamnet.zerotohero.threads.counter.Counter;
+
+/**
+ * Created by Buli on 28.10.2014.
+ */
+public class ClassThread extends Thread{
+
+ @Override
+ public void run(){
+ System.out.println("Thread class extended");
+ }
+
+}
diff --git a/ exercises/teamnet/src/main/java/ro/teamnet/zerotohero/threads/thread_creation/ThreadTester.java b/ exercises/teamnet/src/main/java/ro/teamnet/zerotohero/threads/thread_creation/ThreadTester.java
new file mode 100644
index 0000000..7f00c53
--- /dev/null
+++ b/ exercises/teamnet/src/main/java/ro/teamnet/zerotohero/threads/thread_creation/ThreadTester.java
@@ -0,0 +1,26 @@
+package ro.teamnet.zerotohero.threads.thread_creation;
+
+import com.sun.media.sound.EmergencySoundbank;
+
+/**
+ * Created by Buli on 28.10.2014.
+ */
+public class ThreadTester {
+
+ public static void main (String[] Args){
+ ThreadTester myThread = new ThreadTester();
+
+ Thread newThread = new ClassThread();
+ newThread.run();
+
+ System.out.println("newThread priority:" + newThread.getPriority());
+ System.out.println("newThread name:" + newThread.getName());
+
+ newThread.setPriority(10);
+ newThread.setName("Exercise 3");
+
+ System.out.println("newThread priority:" + newThread.getPriority());
+ System.out.println("newThread name:" + newThread.getName());
+ }
+
+}
diff --git a/ exercises/teamnet/student.data b/ exercises/teamnet/student.data
new file mode 100644
index 0000000..7ed30d1
Binary files /dev/null and b/ exercises/teamnet/student.data differ
diff --git a/ exercises/teamnet/teamnet.iml b/ exercises/teamnet/teamnet.iml
new file mode 100644
index 0000000..08ae11a
--- /dev/null
+++ b/ exercises/teamnet/teamnet.iml
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/ exercises/warm-up/pom.xml b/ exercises/warm-up/pom.xml
new file mode 100644
index 0000000..2ccc729
--- /dev/null
+++ b/ exercises/warm-up/pom.xml
@@ -0,0 +1,19 @@
+
+
+ 4.0.0
+
+ groupId
+ warm-up
+ 1.0-SNAPSHOT
+
+
+
+ junit
+ junit
+ 4.11
+
+
+
+
\ No newline at end of file
diff --git a/ exercises/warm-up/src/main/java/exercise/exercise0/Exercise0.java b/ exercises/warm-up/src/main/java/exercise/exercise0/Exercise0.java
new file mode 100644
index 0000000..9a38bc0
--- /dev/null
+++ b/ exercises/warm-up/src/main/java/exercise/exercise0/Exercise0.java
@@ -0,0 +1,79 @@
+package exercise.exercise0;
+
+import java.util.ArrayList;
+import java.util.LinkedList;
+import java.util.ListIterator;
+
+/**
+ * Created by Radu.Hoaghe on 10/29/2014.
+ *
+ * Exercise 0: Create a List (ArrayList or LinkedList), add elements to it and print all of them using ListIterator
+ * for loop and foreach loop
+ *
+ */
+public class Exercise0 {
+
+ public Exercise0(){
+
+ }
+
+ public void iterateThroughList(){
+
+ // TODO Exercise #0 a) Create a list (ArrayList or LinkedList) and add elements to it
+
+ ArrayList myList = new ArrayList(5);
+ myList.add(1);
+ myList.add(2);
+ myList.add(3);
+ myList.add(4);
+ myList.add(5);
+
+ // TODO Exercise #0 a) Don't forget to specify the type of the list (Integer, String etc.)
+
+ // TODO Exercise #0 b) Iterate through the list using ListIterator and print all its elements
+
+ ListIterator it = myList.listIterator();
+ System.out.print("List elements: ");
+ while(it.hasNext()){
+ int element = it.next();
+
+ System.out.print(element + ", ");
+ }
+
+ // TODO Exercise #0 c) Iterate through the list using for loop and print all its elements
+ System.out.println();
+ System.out.print("For loop ->");
+ System.out.print("List elements: ");
+ for(int counter=0; counter");
+ System.out.print("List elements: ");
+ it = myList.listIterator();
+ for(Integer element : myList){
+
+ System.out.print(element + ", ");
+ }
+
+ //backward iterator
+ System.out.println();
+ System.out.println("Iterator backward");
+ System.out.print("List elements: ");
+ it = myList.listIterator();
+ while(it.hasPrevious()){
+ int element = it.previous();
+
+ System.out.print(element + ", ");
+ }
+ }
+
+ public static void main(String[] args) {
+ // TODO Exercise #0 e) Create a new instance of Exercise0 class and call the iterateThroughList() method
+ Exercise0 newEx = new Exercise0();
+ newEx.iterateThroughList();
+ }
+}
diff --git a/ exercises/warm-up/src/main/java/exercise/exercise1/Exercise1.java b/ exercises/warm-up/src/main/java/exercise/exercise1/Exercise1.java
new file mode 100644
index 0000000..9cbe65b
--- /dev/null
+++ b/ exercises/warm-up/src/main/java/exercise/exercise1/Exercise1.java
@@ -0,0 +1,101 @@
+package exercise.exercise1;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.ListIterator;
+
+/**
+ * Created by Radu.Hoaghe on 10/28/2014.
+ *
+ * Exercise 1: Compute the sum, the minimum and the maximum element from a given list (givenList) using three
+ * different ways to iterate over a List:
+ * a) ListIterator (implement it in the iterateUsingListIterator() method)
+ * b) for loop (implement it in the iterateUsingForLoop() method)
+ * c) foreach loop (implement it in the iterateUsingForEachLoop() method)
+ *
+ * In order to test your implementations you need to run the Exercise1Test from the test/java package
+ * (right-click on Exercise1Test class then click Run 'Exercise1Test' )
+ */
+public class Exercise1{
+ private List givenList;
+
+ public Exercise1(List l) {
+ this.givenList = l;
+ }
+
+ // TODO Exercise #1 a) Compute sum and get the min and the max from above 'givenList' iterating through it using ListIterator
+ public List iterateUsingListIterator(){
+ // This List is used only for testing so you don't need to modify it
+ List testValues = new ArrayList();
+
+
+ // TODO Exercise #1 a1) In order to pass the tests you need to name your variables sum, min and max or if
+ // TODO Exercise #1 a1) you want to name them differently you need to modify when you add them to testValues below
+ int sum=0, max=givenList.get(0), min=givenList.get(0);
+ ListIterator it = givenList.listIterator();
+ while(it.hasNext()){
+ int element = it.next();
+ sum += element;
+ if(element > max)
+ max = element;
+ if(element < min)
+ min = element;
+ }
+
+ // Adding the results to the List in order to be tested
+ // TODO Exercise #1 a2) Uncomment the following three lines in order to test your implementation
+ testValues.add(sum);
+ testValues.add(min);
+ testValues.add(max);
+
+ return testValues;
+ }
+
+ // TODO Exercise #0 b) Compute sum and get the min and the max from list iterating through it using foreach loop
+ public List iterateUsingForEachLoop(){
+
+ // This List is used only for testing so you don't need to modify it
+ List testValues = new ArrayList();
+
+ int sum=0, max=givenList.get(0), min=givenList.get(0);
+ for(Integer element : givenList){
+ sum += element;
+ if(element > max)
+ max = element;
+ if(element < min)
+ min = element;
+ }
+
+ // Adding the results to the List in order to be tested
+ // TODO Exercise #1 b1) Uncomment the following three lines in order to test your implementation
+ testValues.add(sum);
+ testValues.add(min);
+ testValues.add(max);
+
+ return testValues;
+ }
+
+ public List iterateUsingForLoop(){
+
+ // This List is used only for testing so you don't need to modify it
+ List testValues = new ArrayList();
+
+ int sum=0, max=givenList.get(0), min=givenList.get(0);
+ for(int i=0; i max)
+ max = element;
+ if(element < min)
+ min = element;
+ }
+
+ // Adding the results to the List in order to be tested
+ // TODO Exercise #1 b1) Uncomment the following three lines in order to test your implementation
+ testValues.add(sum);
+ testValues.add(min);
+ testValues.add(max);
+
+ return testValues;
+ }
+}
diff --git a/ exercises/warm-up/src/main/java/exercise/exercise2/MyList.java b/ exercises/warm-up/src/main/java/exercise/exercise2/MyList.java
new file mode 100644
index 0000000..c91757a
--- /dev/null
+++ b/ exercises/warm-up/src/main/java/exercise/exercise2/MyList.java
@@ -0,0 +1,139 @@
+package exercise.exercise2;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.ListIterator;
+
+/**
+ * Created by Radu.Hoaghe on 28.10.2014.
+ *
+ * Exercise 2: Create a class that inherits ArrayList (class MyList).
+ *
+ * This list (MyList) should have the following functionality, besides the functionality
+ * that ArrayList already offers: it should retain in every moment how many different
+ * elements exist in the list.
+ *
+ * Examples: 1. If you have a List that contains: 7 5 3 2 4 1, there are 6 different elements.
+ * 2. If you have a List that contains: 5 6 1 2 5 6, there are 4 different elements.
+ *
+ * A variable that retains the number of different elements that exist in the list in
+ * every moment was already defined (differentElements).
+ *
+ * First of all, you will need to override the add methods so that every time a different
+ * element is added the counter will be updated.
+ * Hint : check out the List documentation to see the methods signatures.
+ *
+ * Secondly, you will also need to override the remove methods (Hint: Of course the List
+ * documentation) because the number of different elements in the list could change if
+ * the last element of its kind in the list is removed and by not overrriding it the
+ * counter will remain unchanged.
+ *
+ * Finally, you will need to override the clear method and create a getter method for the
+ * counter (in order to access it outside the class).
+ *
+ * In order to add/remove/clear the elements into/from the list you will need to use the
+ * add/remove/clear methods inherited from ArrayList.
+ *
+ * To test your implementation run the Exercise2Test class.
+ *
+ */
+public class MyList extends ArrayList {
+
+ // A counter to hold the number of adds that were made on the list
+ private int differentElements;
+
+ public MyList(){
+ super();
+ differentElements = 0;
+ }
+
+ // TODO Exercise #2 a) Override add() and addAll() methods so that the list should retain the number of
+ // TODO Exercise #2 a) different elements
+
+ private ArrayList myList = this;
+
+ @Override
+ public boolean add(Integer integer) {
+
+ if (!myList.contains(integer))
+ differentElements ++;
+ return super.add(integer);
+ }
+
+ @Override
+ public boolean addAll(Collection extends Integer> c) {
+ for(Object el : c) {
+ if (!myList.contains(el))
+ differentElements++;
+ }
+ return super.addAll(c);
+ }
+
+ @Override
+ public void add(int index, Integer element) {
+ if (!myList.contains(element))
+ differentElements ++;
+ super.add(index, element);
+ }
+
+ @Override
+ public boolean addAll(int index, Collection extends Integer> c) {
+ for(Object el : c) {
+ if (!myList.contains(el))
+ differentElements++;
+ }
+ return super.addAll(index, c);
+ }
+
+ public int getDifferentElements() {
+ return differentElements;
+ }
+ // TODO Exercise #2 b) Override the remove methods so that the number of different elements is updated when
+ // TODO Exercise #2 b) an element is removed
+ // TODO Exercise #2 b) hint: you need to update the number of different elements only when
+ // TODO Exercise #2 b) the element that needs to be removed is the last element of its kind in the list
+
+ @Override
+ public Integer remove(int index) {
+ Integer el = this.get(index);
+ super.remove(index);
+
+ if(!myList.contains(el))
+ differentElements --;
+ return el;
+ }
+
+ @Override
+ public boolean remove(Object o) {
+ boolean r = super.remove(o);
+ if(!myList.contains(o))
+ differentElements --;
+ return r;
+ }
+
+ /*
+ @Override
+ public boolean removeAll(Collection> c) {
+ boolean ok = false;
+ super.removeAll(c);
+ for(Object el : c) {
+ if (!myList.contains(el))
+ ok = true;
+ }
+ return ok;
+ }
+*/
+ // TODO Exercise #2 c) Override the clear method (hint: don't forget to reset the number of different elements)
+
+ @Override
+ public void clear() {
+ differentElements = 0;
+ super.clear();
+ }
+
+
+ // TODO Exercise #2 d) Generate a getter method in order to get the counter value
+
+ // TODO Exercise #2 e) Uncomment all the lines from Exercise2Test.java in order to test your implementation
+}
diff --git a/ exercises/warm-up/src/main/java/exercise/exercise3/Exercise3.java b/ exercises/warm-up/src/main/java/exercise/exercise3/Exercise3.java
new file mode 100644
index 0000000..a64b52a
--- /dev/null
+++ b/ exercises/warm-up/src/main/java/exercise/exercise3/Exercise3.java
@@ -0,0 +1,59 @@
+package exercise.exercise3;
+
+import java.util.*;
+
+/**
+ * Created by Radu.Hoaghe on 10/28/2014.
+ *
+ * Exercise 3: Fill three Set implementations that you know (Hint: they were described during
+ * the earlier presentation) with the List that is given to this class by
+ * its constructor.
+ *
+ * Check out the elements that the list mentioned above contains and then, add them
+ * to your three Sets. After this check out the elements of your Sets. What do you
+ * remark? What could be the reason?
+ *
+ * Finally, add to the one of the three Sets some elements
+ * that already exist in the Set (e.g add("that") and add("collection"))
+ *
+ * To run your implementation, run the Exercise3Test class.
+ */
+public class Exercise3 {
+
+ // List containing some elements that need to be added into the Set
+ private List listToAdd;
+
+ public Exercise3(List l) {
+ listToAdd = l;
+ }
+
+ public void addElementsToSets(){
+ // hint: you should create an instance for every type of discussed Set implementation
+
+ HashSet hashSet = new HashSet();
+ LinkedHashSet linkedHashSet = new LinkedHashSet();
+ TreeSet treeSet = new TreeSet();
+
+ System.out.println("The elements that will be added to the Sets: ");
+ // TODO Exercise #3 a) Print the content of the elements you will add into the Set
+ ListIterator it = listToAdd.listIterator();
+ while (it.hasNext()){
+ System.out.println(it.next());
+ }
+ // TODO Exercise #3 b) add the elements from listToAdd to the Sets
+ hashSet.addAll(listToAdd);
+ linkedHashSet.addAll(listToAdd);
+ treeSet.addAll(listToAdd);
+
+ // TODO Exercise #3 c) Print the content of the Sets
+ System.out.println("HashSet: " + hashSet.toString());
+ System.out.println("LinkedHashSet" + linkedHashSet.toString());
+ System.out.println("TreeHashSet" + treeSet.toString());
+
+ // TODO Exercise #3 d) Add to the TreeSet two elements that already exist in the Set
+ treeSet.add("no");
+ treeSet.add("that");
+ // TODO Exercise #3 d) and print again the TreeSet. What do you see?
+ System.out.println("TreeHashSet" + treeSet.toString());
+ }
+}
diff --git a/ exercises/warm-up/src/test/java/Exercise1Test.java b/ exercises/warm-up/src/test/java/Exercise1Test.java
new file mode 100644
index 0000000..3f7cf75
--- /dev/null
+++ b/ exercises/warm-up/src/test/java/Exercise1Test.java
@@ -0,0 +1,53 @@
+import exercise.exercise1.Exercise1;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+/**
+ * Created by Radu.Hoaghe on 10/29/2014.
+ */
+public class Exercise1Test {
+ private Integer[] v = {15, 5, 34, 23, 7, 19, 20, 22, 78, 39, 8, 30, 27, 62, 28, 7};
+ private List listToTest;
+ private List expected;
+
+ private Exercise1 ex1;
+
+ @Before
+ public void setUp() throws Exception {
+ listToTest = Arrays.asList(v);
+ ex1 = new Exercise1(listToTest);
+ expected = new ArrayList();
+ expected.add(424); // sum
+ expected.add(5); // min
+ expected.add(78); // max
+ }
+
+ @Test
+ public void testIterator() throws Exception {
+ List testResults = ex1.iterateUsingListIterator();
+ Assert.assertEquals("Test sum with iterator", expected.get(0), testResults.get(0));
+ Assert.assertEquals("Test min with iterator", expected.get(1), testResults.get(1));
+ Assert.assertEquals("Test max with iterator", expected.get(2), testResults.get(2));
+ }
+
+ @Test
+ public void testFor() throws Exception {
+ List testResults = ex1.iterateUsingForLoop();
+ Assert.assertEquals("Test sum with for", expected.get(0), testResults.get(0));
+ Assert.assertEquals("Test min with for", expected.get(1), testResults.get(1));
+ Assert.assertEquals("Test max with for", expected.get(2), testResults.get(2));
+ }
+
+ @Test
+ public void testForEach() throws Exception {
+ List testResults = ex1.iterateUsingForEachLoop();
+ Assert.assertEquals("Test sum with foreach", expected.get(0), testResults.get(0));
+ Assert.assertEquals("Test min with foreach", expected.get(1), testResults.get(1));
+ Assert.assertEquals("Test max with foreach", expected.get(2), testResults.get(2));
+ }
+}
diff --git a/ exercises/warm-up/src/test/java/Exercise2Test.java b/ exercises/warm-up/src/test/java/Exercise2Test.java
new file mode 100644
index 0000000..0af58e3
--- /dev/null
+++ b/ exercises/warm-up/src/test/java/Exercise2Test.java
@@ -0,0 +1,157 @@
+import exercise.exercise2.MyList;
+import junit.framework.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+import java.util.Arrays;
+
+/**
+* Created by Radu.Hoaghe on 10/29/2014.
+*/
+public class Exercise2Test {
+ private MyList listToTest;
+ private int addExpectedTest1, addExpectedTest2;
+ private int insertExpectedTest1;
+ private int removeExpectedTest1, removeExpectedTest2;
+ private int addAllExpectedTest1, addAllExpectedTest2;
+ private Integer[] v = new Integer[5];
+
+ @Before
+ public void setUp() throws Exception {
+ listToTest = new MyList();
+ addExpectedTest1 = 10;
+ addExpectedTest2 = 11;
+ insertExpectedTest1 = 13;
+ addAllExpectedTest1 = 10;
+ addAllExpectedTest2 = 13;
+ removeExpectedTest1 = 8;
+ removeExpectedTest2 = 8;
+ }
+
+ @Test
+ public void testAdd() throws Exception {
+ listToTest.clear();
+ Assert.assertEquals("Test clear method", 0, listToTest.getDifferentElements());
+
+ for(int i = 0; i < 10; i++)
+ listToTest.add(i);
+
+ Assert.assertEquals("Test add method with all different elements", addExpectedTest1, listToTest.getDifferentElements());
+
+ listToTest.add(5);
+ listToTest.add(3);
+ listToTest.add(11);
+ listToTest.add(8);
+
+ Assert.assertEquals("Test add method with some equal elements", addExpectedTest2, listToTest.getDifferentElements());
+ }
+
+ @Test
+ public void testAddAtIndex() throws Exception {
+ listToTest.clear();
+ Assert.assertEquals("Test clear method", 0, listToTest.getDifferentElements());
+
+
+ for(int i = 0; i < 10; i++)
+ listToTest.add(i);
+
+ listToTest.add(8, 11);
+ listToTest.add(5, 12);
+ listToTest.add(3, 13);
+
+ Assert.assertEquals("Test insert different elements", insertExpectedTest1, listToTest.getDifferentElements());
+
+ listToTest.add(7, 8);
+ listToTest.add(4, 4);
+ listToTest.add(5, 12);
+
+ Assert.assertEquals("Test insert equal elements", insertExpectedTest1, listToTest.getDifferentElements());
+
+ }
+
+ @Test
+ public void testAddAll() throws Exception {
+ listToTest.clear();
+ Assert.assertEquals("Test clear method", 0, listToTest.getDifferentElements());
+
+ for(int i = 0; i < 10; i++)
+ listToTest.add(i);
+
+ for(int i = 0; i < 5; i++)
+ v[i] = i;
+
+ listToTest.addAll(Arrays.asList(v));
+ Assert.assertEquals("Test addAll with all equal elements", addAllExpectedTest1, listToTest.getDifferentElements());
+
+ for(int i = 0; i < 5; i++)
+ v[i] = 5 * i;
+
+ listToTest.addAll(Arrays.asList(v));
+ Assert.assertEquals("Test addAll with all some different elements", addAllExpectedTest2, listToTest.getDifferentElements());
+
+ }
+
+ @Test
+ public void testAddAllAtIndex() throws Exception {
+ listToTest.clear();
+ Assert.assertEquals("Test clear method", 0, listToTest.getDifferentElements());
+
+ for(int i = 0; i < 10; i++)
+ listToTest.add(i);
+
+ for(int i = 0; i < 5; i++)
+ v[i] = i;
+
+ listToTest.addAll(5, Arrays.asList(v));
+ Assert.assertEquals("Test addAll with all equal elements", addAllExpectedTest1, listToTest.getDifferentElements());
+
+ for(int i = 0; i < 5; i++)
+ v[i] = 5 * i;
+
+ listToTest.addAll(10, Arrays.asList(v));
+ Assert.assertEquals("Test addAll with some different elements", addAllExpectedTest2, listToTest.getDifferentElements());
+
+ }
+
+ @Test
+ public void testRemove() throws Exception {
+ listToTest.clear();
+ Assert.assertEquals("Test clear method", 0, listToTest.getDifferentElements());
+
+ for(int i = 0; i < 10; i++)
+ listToTest.add(i);
+
+ listToTest.remove(5);
+ listToTest.remove(3);
+
+ Assert.assertEquals("Test remove elements with 1 occurence", removeExpectedTest1, listToTest.getDifferentElements());
+
+ listToTest.add(7);
+ listToTest.add(7);
+ listToTest.remove(5);
+
+ Assert.assertEquals("Test remove element with 3 occurences", removeExpectedTest2, listToTest.getDifferentElements());
+
+ }
+
+ @Test
+ public void testRemoveObject() throws Exception {
+ listToTest.clear();
+ Assert.assertEquals("Test clear method", 0, listToTest.getDifferentElements());
+
+ for(int i = 0; i < 10; i++)
+ listToTest.add(i);
+
+ listToTest.remove((Integer) 5);
+ listToTest.remove((Integer) 3);
+
+ Assert.assertEquals("Test remove elements with 1 occurence", removeExpectedTest1, listToTest.getDifferentElements());
+
+ listToTest.add(7);
+ listToTest.add(7);
+ listToTest.remove((Integer) 7);
+
+ Assert.assertEquals("Test remove element with 3 occurences", removeExpectedTest2, listToTest.getDifferentElements());
+
+ }
+}
diff --git a/ exercises/warm-up/src/test/java/Exercise3Test.java b/ exercises/warm-up/src/test/java/Exercise3Test.java
new file mode 100644
index 0000000..5fd7b7e
--- /dev/null
+++ b/ exercises/warm-up/src/test/java/Exercise3Test.java
@@ -0,0 +1,25 @@
+import exercise.exercise3.Exercise3;
+import org.junit.Before;
+import org.junit.Test;
+
+import java.util.Arrays;
+
+/**
+ * Created by Radu.Hoaghe on 10/29/2014.
+ */
+public class Exercise3Test {
+ private Exercise3 exercise3;
+ private String[] stringsToAddToSet = {"A", "collection", "that", "contains", "no", "duplicate", "elements", "."};
+
+ @Before
+ public void setUp() throws Exception {
+ exercise3 = new Exercise3(Arrays.asList(stringsToAddToSet));
+
+ }
+
+ @Test
+ public void testExercise3() throws Exception {
+ exercise3.addElementsToSets();
+
+ }
+}
diff --git a/ exercises/warm-up2/pom.xml b/ exercises/warm-up2/pom.xml
new file mode 100644
index 0000000..9913300
--- /dev/null
+++ b/ exercises/warm-up2/pom.xml
@@ -0,0 +1,19 @@
+
+
+ 4.0.0
+
+ warm-up2
+ warm-up2
+ 1.0-SNAPSHOT
+
+
+
+ junit
+ junit
+ 4.11
+
+
+
+
\ No newline at end of file
diff --git a/ exercises/warm-up2/src/main/java/exercise0/Exercise0.java b/ exercises/warm-up2/src/main/java/exercise0/Exercise0.java
new file mode 100644
index 0000000..8b42247
--- /dev/null
+++ b/ exercises/warm-up2/src/main/java/exercise0/Exercise0.java
@@ -0,0 +1,50 @@
+package exercise0;
+
+import java.util.*;
+
+/**
+ * Created by Radu.Hoaghe on 10/29/2014.
+ *
+ * Exercise 0: Iterate over the keys of a Map using keySet method (this method returns a Set of all the map keys)
+ */
+public class Exercise0 {
+
+ public Exercise0(){
+
+ }
+
+ // TODO Exercise #0 a) iterate over a Map's keys using keySet method
+ public void iterateThroughMap(){
+
+ Map myMap = new HashMap();
+ myMap.put("a1",1);
+ myMap.put("a2",2);
+ myMap.put("a3",3);
+ myMap.put("a4",4);
+ myMap.put("b1",1);
+ myMap.put("b2",2);
+ myMap.put("b3",3);
+ myMap.put("b4",4);
+ Set mySet = myMap.keySet();
+ Iterator it = mySet.iterator();
+ while(it.hasNext()){
+ System.out.println(it.next());
+ }
+
+ // TODO Exercise #0 b) Create a Map (HashMap) and add elements to it (using put() method)
+ // TODO Exercise #0 b) Don't forget to specify the types of the key and value when creating the Map
+
+ // TODO Exercise #0 c) Iterate over the Map using keySet() method and print all its elements
+ // TODO Exercise #0 c) The elements are printed like this: [key1=value1, key2=value2, ...]
+
+ for(String s : mySet){
+ System.out.println("[" + s + " = " +myMap.get(s) + "]");
+ }
+
+ }
+
+ public static void main(String[] args) {
+ Exercise0 exercise0 = new Exercise0();
+ exercise0.iterateThroughMap();
+ }
+}
diff --git a/ exercises/warm-up2/src/main/java/exercise1/Exercise1.java b/ exercises/warm-up2/src/main/java/exercise1/Exercise1.java
new file mode 100644
index 0000000..13cf5cb
--- /dev/null
+++ b/ exercises/warm-up2/src/main/java/exercise1/Exercise1.java
@@ -0,0 +1,82 @@
+package exercise1;
+
+import com.sun.corba.se.impl.encoding.OSFCodeSetRegistry;
+
+import java.util.*;
+
+/**
+ * Created by Radu.Hoaghe on 10/29/2014.
+ *
+ * Exercise 1: You have a Map that holds in each element a country with its capital (countries Map)
+ * a) Find all the countries that start with 'R' character, iterating through the keys of the Map using
+ * keySet() method
+ * b) Find all the countries that start with 'R' character, iterating through the keys of the Map using
+ * Map.Entry, and convert all the characters of the countries found to lowercase
+ * c) Find the capital city with the longest name, iterating through the values of the Map (values() method)
+ *
+ */
+public class Exercise1 {
+
+ // A map that holds some key-value pairs, the key represents the country and its value represents
+ // the capital city of the country
+ private Map countries;
+
+ public Exercise1(Map countries){
+ this.countries = countries;
+ }
+
+ // TODO Exercise #1 a) You need to iterate over the map keys using a foreach loop (see Map.keySet())
+ // TODO Exercise #1 a) and add the countries that start with 'R' character into the seekingCountries list
+ // TODO Exercise #1 a) hint: see String documentation
+ public List iteratingOverKeys(){
+
+ // The list of countries that start with the 'R' character
+ List seekingCountries = new ArrayList();
+ Set mySet = countries.keySet();
+ for(String country : mySet){
+ if(country.startsWith("R") || country.startsWith("r"))
+ seekingCountries.add(country);
+ }
+
+ return seekingCountries;
+ }
+
+ // TODO Exercise #1 b) You need to iterate over the map entries using a foreach loop (see Map.Entry)
+ // TODO Exercise #1 b) and convert to lowercase (hint: String documentation) all the countries that start with 'R'
+ // TODO Exercise #1 b) character into the seekingCountries list
+ public List iteratingOverEntries(){
+
+ // The list of countries that start with the 'R' character and will be converted to lowercase
+ List seekingCountries = new ArrayList();
+
+ Set> mySet2 = countries.entrySet();
+
+ for(Map.Entry country : mySet2){
+ if(country.getKey().startsWith("R"))
+ seekingCountries.add(country.getKey().toLowerCase());
+ }
+
+ return seekingCountries;
+ }
+
+ // TODO Exercise #1 c) You need to iterate over the map values using a foreach loop (see Map.values())
+ // TODO Exercise #1 c) and find the capital city with the longest name
+ public String iteratingOverValues(){
+
+ // The country that has the capital city with the longest name
+ String seekingCapital = "";
+
+ int max = seekingCapital.length();
+
+ Collection myColl = countries.values();
+
+ for(String value : myColl){
+ if(value.length() > max){
+ max = value.length();
+ seekingCapital = value;
+ }
+ }
+
+ return seekingCapital;
+ }
+}
diff --git a/ exercises/warm-up2/src/main/java/exercise2/Exercise2.java b/ exercises/warm-up2/src/main/java/exercise2/Exercise2.java
new file mode 100644
index 0000000..601eacb
--- /dev/null
+++ b/ exercises/warm-up2/src/main/java/exercise2/Exercise2.java
@@ -0,0 +1,70 @@
+package exercise2;
+
+import java.util.*;
+
+/**
+ * Created by Radu.Hoaghe on 10/30/2014.
+ *
+ * Exercise 2: Overriding equals() and hashCode() methods.
+ * Create a Set and a Map and add some elements to them before and after overriding equals() and hashCode()
+ * For this exercise you need to follow in order all the TODO steps.
+ */
+public class Exercise2 {
+ private List studentList;
+ private List cnps;
+
+ public Exercise2(List studentList, List cnps){
+ this.studentList = studentList;
+ this.cnps = cnps;
+ }
+
+ public void addStudents(){
+
+ //System.out.println("The list of students is: " + studentList);
+
+ // TODO Exercise 2 a) Make a new Set, add the elements from the studentList into it
+ Set mySet = new HashSet();
+ mySet.addAll(studentList);
+// System.out.println(mySet.toString());
+//
+// mySet.clear();
+//
+// mySet.addAll(studentList);
+// System.out.println(mySet.toString());
+//
+// mySet.clear();
+//
+// mySet.addAll(studentList);
+// System.out.println(mySet.toString());
+
+ Map myMap = new HashMap();
+ List list = new ArrayList(mySet);
+
+ int counter = 0;
+ for(int i=0;i so that it holds in the key all the Students from the
+ // TODO (Important !) Set you have just already created, and in the keys' value, the CNP of the Student found in cnps List
+ // TODO (suggestion: after you implement this, you could comment, firstly, the equals() method from Student class
+ // TODO and then the hashCode() method in order to see some differences).
+
+ }
+}
diff --git a/ exercises/warm-up2/src/main/java/exercise2/Student.java b/ exercises/warm-up2/src/main/java/exercise2/Student.java
new file mode 100644
index 0000000..83d19cb
--- /dev/null
+++ b/ exercises/warm-up2/src/main/java/exercise2/Student.java
@@ -0,0 +1,67 @@
+package exercise2;
+
+/**
+ * Created by Radu.Hoaghe on 31.10.2014.
+ */
+public class Student {
+ private final String firstName;
+ private final String lastName;
+ private final Double averageGrade;
+
+ public Student(String firstName, String lastName, Double averageGrade) {
+ this.firstName = firstName;
+ this.lastName = lastName;
+ this.averageGrade = averageGrade;
+ }
+
+ public String getFirstName() {
+ return firstName;
+ }
+
+ public String getLastName() {
+ return lastName;
+ }
+
+ public Double getAverageGrade() {
+ return averageGrade;
+ }
+
+ // TODO Exercise 2 c) Override the equals() method
+ @Override
+ public boolean equals(Object o) {
+ // TODO Exercise 2 c1) Check if the current instance is the same instance as the one from Object o
+ if(this == o) return true;
+ // TODO Exercise 2 c2) Check if Object o is null
+ if(o == null || getClass() != o.getClass()) return false;
+
+ // TODO Exercise 2 c3) Cast the object into a Student variable
+ Student stud = (Student) o;
+ // TODO Exercise 2 c3) Check if all the fields from Student class are equal to the ones from
+ if(!firstName.equals(stud.firstName)) return false;
+ if(!lastName.equals(stud.lastName)) return false;
+ if(!averageGrade.equals (stud.averageGrade)) return false;
+ // TODO Exercise 2 c3) the variable that you casted earlier (lastName, firstName, averageGrade)
+
+ return true;
+ // TODO Exercise 2 d) After you finished implementing equals method go to TODO Exercise 2 e) from Exercise2 class
+ }
+
+ // TODO Exercise 2 g) Override the hashCode() method
+ // TODO Exercise 2 g) Hint: Don't forget to include in the hashCode result all the fields from
+ // TODO Exercise 2 g) the Student class
+ @Override
+ public int hashCode() {
+ int result = firstName.hashCode();
+ result = 31 * result + lastName.hashCode();
+ result = 31 * result + averageGrade.hashCode();
+ //result = 31 * result;
+ return result;
+ // TODO Exercise 2 h) After you finished implementing hashCode go to TODO Exercise 2 i) from Exercise2 class
+ }
+
+ // TODO You should override the toString() method in order to print the Student class' elements
+ @Override
+ public String toString() {
+ return "Student " + firstName + " " + lastName + " average grade= " + averageGrade;
+ }
+}
diff --git a/ exercises/warm-up2/src/test/java/Exercise1Test.java b/ exercises/warm-up2/src/test/java/Exercise1Test.java
new file mode 100644
index 0000000..e53f644
--- /dev/null
+++ b/ exercises/warm-up2/src/test/java/Exercise1Test.java
@@ -0,0 +1,159 @@
+import exercise1.Exercise1;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Created by Radu.Hoaghe on 10/29/2014.
+ */
+public class Exercise1Test {
+ public static final String[][] data = {
+ // Africa
+ {"ALGERIA","Algiers"}, {"ANGOLA","Luanda"},
+ {"BENIN","Porto-Novo"}, {"BOTSWANA","Gaberone"},
+ {"BURKINA FASO","Ouagadougou"}, {"BURUNDI","Bujumbura"},
+ {"CAMEROON","Yaounde"}, {"CAPE VERDE","Praia"},
+ {"CENTRAL AFRICAN REPUBLIC","Bangui"},
+ {"CHAD","N’djamena"}, {"COMOROS","Moroni"},
+ {"CONGO","Brazzaville"}, {"DJIBOUTI","Dijibouti"},
+ {"EGYPT","Cairo"}, {"EQUATORIAL GUINEA","Malabo"},
+ {"ERITREA","Asmara"}, {"ETHIOPIA","Addis Ababa"},
+ {"GABON","Libreville"}, {"THE GAMBIA","Banjul"},
+ {"GHANA","Accra"}, {"GUINEA","Conakry"},
+ {"BISSAU","Bissau"}, {"COTE D’IVOIRE (IVORY COAST)","Yamoussoukro"},
+ {"KENYA","Nairobi"}, {"LESOTHO","Maseru"},
+ {"LIBERIA","Monrovia"}, {"LIBYA","Tripoli"},
+ {"MADAGASCAR","Antananarivo"}, {"MALAWI","Lilongwe"},
+ {"MALI","Bamako"}, {"MAURITANIA","Nouakchott"},
+ {"MAURITIUS","Port Louis"}, {"MOROCCO","Rabat"},
+ {"MOZAMBIQUE","Maputo"}, {"NAMIBIA","Windhoek"},
+ {"NIGER","Niamey"}, {"NIGERIA","Abuja"},
+ {"RWANDA","Kigali"}, {"SAO TOME E PRINCIPE","Sao Tome"},
+ {"SENEGAL","Dakar"}, {"SEYCHELLES","Victoria"},
+ {"SIERRA LEONE","Freetown"}, {"SOMALIA","Mogadishu"},
+ {"SOUTH AFRICA","Pretoria/Cape Town"},
+ {"SUDAN","Khartoum"}, {"SWAZILAND","Mbabane"}, {"TANZANIA","Dodoma"},
+ {"TOGO","Lome"}, {"TUNISIA","Tunis"},
+ {"UGANDA","Kampala"},{"DEMOCRATIC REPUBLIC OF THE CONGO (ZAIRE)", "Kinshasa"},
+ {"ZAMBIA","Lusaka"}, {"ZIMBABWE","Harare"},
+ // Asia
+ {"AFGHANISTAN","Kabul"}, {"BAHRAIN","Manama"},
+ {"BANGLADESH","Dhaka"}, {"BHUTAN","Thimphu"},
+ {"BRUNEI","Bandar Seri Begawan"},
+ {"CAMBODIA","Phnom Penh"},
+ {"CHINA","Beijing"}, {"CYPRUS","Nicosia"},
+ {"INDIA","New Delhi"}, {"INDONESIA","Jakarta"},
+ {"IRAN","Tehran"}, {"IRAQ","Baghdad"},
+ {"ISRAEL","Jerusalem"}, {"JAPAN","Tokyo"},
+ {"JORDAN","Amman"}, {"KUWAIT","Kuwait City"},
+ {"LAOS","Vientiane"}, {"LEBANON","Beirut"},
+ {"MALAYSIA","Kuala Lumpur"}, {"THE MALDIVES","Male"},
+ {"MONGOLIA","Ulan Bator"}, {"MYANMAR (BURMA)","Rangoon"},
+ {"NEPAL","Katmandu"}, {"NORTH KOREA","P’yongyang"},
+ {"OMAN","Muscat"}, {"PAKISTAN","Islamabad"},
+ {"PHILIPPINES","Manila"}, {"QATAR","Doha"},
+ {"SAUDI ARABIA","Riyadh"}, {"SINGAPORE","Singapore"},
+ {"SOUTH KOREA","Seoul"}, {"SRI LANKA","Colombo"},
+ {"SYRIA","Damascus"}, {"TAIWAN (REPUBLIC OF CHINA)","Taipei"},
+ {"THAILAND","Bangkok"}, {"TURKEY","Ankara"},
+ {"UNITED ARAB EMIRATES","Abu Dhabi"},
+ {"VIETNAM","Hanoi"}, {"YEMEN","Sana’a"},
+ // Australia and Oceania
+ {"AUSTRALIA","Canberra"}, {"FIJI","Suva"},
+ {"KIRIBATI","Bairiki"},{"MARSHALL ISLANDS","Dalap-Uliga-Darrit"},
+ {"MICRONESIA","Palikir"}, {"NAURU","Yaren"},
+ {"NEW ZEALAND","Wellington"}, {"PALAU","Koror"},
+ {"PAPUA NEW GUINEA","Port Moresby"},
+ {"SOLOMON ISLANDS","Honaira"}, {"TONGA","Nuku’alofa"},
+ {"TUVALU","Fongafale"}, {"VANUATU","Port-Vila"},
+ {"WESTERN SAMOA","Apia"},
+ // Eastern Europe and former USSR
+ {"ARMENIA","Yerevan"}, {"AZERBAIJAN","Baku"},
+ {"BELARUS (BYELORUSSIA)","Minsk"},
+ {"BULGARIA","Sofia"}, {"GEORGIA","Tbilisi"},
+ {"KAZAKSTAN","Almaty"}, {"KYRGYZSTAN","Alma-Ata"},
+ {"MOLDOVA","Chisinau"}, {"RUSSIA","Moscow"},
+ {"TAJIKISTAN","Dushanbe"}, {"TURKMENISTAN","Ashkabad"},
+ {"UKRAINE","Kyiv"}, {"UZBEKISTAN","Tashkent"},
+ // Europe
+ {"ALBANIA","Tirana"}, {"ANDORRA","Andorra la Vella"},
+ {"AUSTRIA","Vienna"}, {"BELGIUM","Brussels"},
+ {"BOSNIA-HERZEGOVINA","Sarajevo"},
+ {"CROATIA","Zagreb"}, {"CZECH REPUBLIC","Prague"},
+ {"DENMARK","Copenhagen"}, {"ESTONIA","Tallinn"},
+ {"FINLAND","Helsinki"}, {"FRANCE","Paris"},
+ {"GERMANY","Berlin"}, {"GREECE","Athens"},
+ {"HUNGARY","Budapest"}, {"ICELAND","Reykjavik"},
+ {"IRELAND","Dublin"}, {"ITALY","Rome"},
+ {"LATVIA","Riga"}, {"LIECHTENSTEIN","Vaduz"},
+ {"LITHUANIA","Vilnius"}, {"LUXEMBOURG","Luxembourg"},
+ {"MACEDONIA","Skopje"}, {"MALTA","Valletta"},
+ {"MONACO","Monaco"}, {"MONTENEGRO","Podgorica"},
+ {"THE NETHERLANDS","Amsterdam"}, {"NORWAY","Oslo"},
+ {"POLAND","Warsaw"}, {"PORTUGAL","Lisbon"},
+ {"ROMANIA","Bucharest"}, {"SAN MARINO","San Marino"},
+ {"SERBIA","Belgrade"}, {"SLOVAKIA","Bratislava"},
+ {"SLOVENIA","Ljuijana"}, {"SPAIN","Madrid"},
+ {"SWEDEN","Stockholm"}, {"SWITZERLAND","Berne"},
+ {"UNITED KINGDOM","London"}, {"VATICAN CITY","Vatican"},
+ // North and Central America
+ {"ANTIGUA AND BARBUDA","Saint John’s"}, {"BAHAMAS","Nassau"},
+ {"BARBADOS","Bridgetown"}, {"BELIZE","Belmopan"},
+ {"CANADA","Ottawa"}, {"COSTA RICA","San Jose"},
+ {"CUBA","Havana"}, {"DOMINICA","Roseau"},
+ {"DOMINICAN REPUBLIC","Santo Domingo"},
+ {"EL SALVADOR","San Salvador"}, {"GRENADA","Saint George’s"},
+ {"GUATEMALA","Guatemala City"}, {"HAITI","Port-au-Prince"},
+ {"HONDURAS","Tegucigalpa"}, {"JAMAICA","Kingston"},
+ {"MEXICO","Mexico City"}, {"NICARAGUA","Managua"},
+ {"PANAMA","Panama City"}, {"ST. KITTS-NEVIS","Basseterre"}, {"ST. LUCIA","Castries"},
+ {"ST. VINCENT AND THE GRENADINES","Kingstown"},
+ {"UNITED STATES OF AMERICA","Washington, D.C."},
+ // South America
+ {"ARGENTINA","Buenos Aires"}, {"BOLIVIA","La Paz"},
+ {"BRAZIL","Brasilia"}, {"CHILE","Santiago"},
+ {"COLOMBIA","Bogota"}, {"ECUADOR","Quito"},
+ {"GUYANA","Georgetown"}, {"PARAGUAY","Asuncion"},
+ {"PERU","Lima"}, {"SURINAME","Paramaribo"},
+ {"TRINIDAD AND TOBAGO","Port of Spain"},
+ {"URUGUAY","Montevideo"}, {"VENEZUELA","Caracas"},
+ };
+ private Exercise1 exercise1;
+ private Map countries;
+ private String[] expected = {"romania", "rwanda", "russia"};
+ private String[] expected2 = {"ROMANIA", "RWANDA", "RUSSIA"};
+ private String expectedCapital = "Bandar Seri Begawan";
+
+ @Before
+ public void setUp() throws Exception {
+ countries = new HashMap();
+ for(String[] countryAndCapital : data){
+ countries.put(countryAndCapital[0], countryAndCapital[1]);
+ }
+ exercise1 = new Exercise1(countries);
+
+ }
+
+ @Test
+ public void testIteratingOverKeys() throws Exception {
+ List testResults = exercise1.iteratingOverKeys();
+ Assert.assertEquals("Test Iterating Over Keys", Arrays.asList(expected2), testResults);
+ }
+
+ @Test
+ public void testIteratingOverEntries() throws Exception {
+ List testResults = exercise1.iteratingOverEntries();
+ Assert.assertEquals("Test Iterating Over Entries", Arrays.asList(expected), testResults);
+ }
+
+ @Test
+ public void testIteratingOverValues() throws Exception {
+ String capital = exercise1.iteratingOverValues();
+ Assert.assertEquals("Test Iterating Over Values", expectedCapital, capital);
+ }
+}
diff --git a/ exercises/warm-up2/src/test/java/Exercise2Test.java b/ exercises/warm-up2/src/test/java/Exercise2Test.java
new file mode 100644
index 0000000..a1b00d7
--- /dev/null
+++ b/ exercises/warm-up2/src/test/java/Exercise2Test.java
@@ -0,0 +1,73 @@
+import exercise2.Exercise2;
+import exercise2.Student;
+import junit.framework.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+/**
+ * Created by radu992 on 31.10.2014.
+ */
+public class Exercise2Test {
+ private Student[] students = {new Student("Popescu", "Mihai", 8.66),
+ new Student("Ionescu", "Ion", 7.92),
+ new Student("Popa", "Cristina", 9.34),
+ new Student("Barbu", "Mihai", 5.01),
+ new Student("Popescu", "Mihai", 8.66),
+ new Student("Serban", "Alin", 9.66),
+ new Student("Georgescu", "Andreea", 5.01),
+ new Student("Popa", "Cristina", 9.34),
+ new Student("Popescu", "Mihai", 8.66),};
+
+ private Long[] cnps = {1851021345131L,
+ 1920617149053L,
+ 1870505168646L,
+ 1870619152998L,
+ 1921204325416L,
+ 1931011351347L};
+
+ private List studentList;
+ private List cnpsList;
+ @Before
+ public void setUp() throws Exception {
+ studentList = new ArrayList(Arrays.asList(students));
+ cnpsList = new ArrayList(Arrays.asList(cnps));
+
+ }
+
+ @Test
+ public void testEqualsMethod() throws Exception {
+ new Exercise2(studentList, cnpsList).addStudents();
+ Student student1 = studentList.get(0); // Mihai Popescu
+ Student student2 = studentList.get(4); // Mihai Popescu
+ Student student3 = studentList.get(8); // Mihai Popescu
+ Assert.assertEquals("Test equals method from student", true, student1.equals(student2));
+
+ Assert.assertEquals("Test reflexitivity on equals method", true, student1.equals(student1));
+
+ Assert.assertEquals("Test symmetry on equals method", student2.equals(student1), student1.equals(student2));
+
+ Assert.assertEquals("Test transitivity on equals method", student1.equals(student3), student1.equals(student2)
+ && student2.equals(student3));
+
+ Assert.assertEquals("Test null on equals method", false, student1.equals(null));
+ }
+
+ @Test
+ public void testHashCodeMethod() throws Exception {
+ Student student1 = studentList.get(0); // Mihai Popescu
+ Student student2 = studentList.get(4); // Mihai Popescu
+ Student student3 = studentList.get(1);
+ Student student4 = new Student("Mihai", "Popescu", 8.98); // Mihai Popescu with other averageGrade
+
+ Assert.assertEquals("Test equal elements to have the same hashCode", student1.hashCode(), student2.hashCode());
+
+ Assert.assertNotSame("Test different elements to have different hashCode", student1.hashCode(), student3.hashCode());
+
+ Assert.assertNotSame("Test different elements that differ by one field to have different hashCode", student1.hashCode(),
+ student4.hashCode());
+ }
+}
diff --git a/ exercises/zth-app/pom.xml b/ exercises/zth-app/pom.xml
new file mode 100644
index 0000000..b08f844
--- /dev/null
+++ b/ exercises/zth-app/pom.xml
@@ -0,0 +1,24 @@
+
+ 4.0.0
+ ro.teamnet.zth
+ zth-app
+ jar
+ 1.0-SNAPSHOT
+ zth-app
+ http://maven.apache.org
+
+
+ junit
+ junit
+ 3.8.1
+ test
+
+
+
+ com.oracle
+ ojdbc6
+ 11.2.0.3
+
+
+
diff --git a/ exercises/zth-app/src/main/java/ro/teamnet/zth/App.java b/ exercises/zth-app/src/main/java/ro/teamnet/zth/App.java
new file mode 100644
index 0000000..adf388c
--- /dev/null
+++ b/ exercises/zth-app/src/main/java/ro/teamnet/zth/App.java
@@ -0,0 +1,90 @@
+package ro.teamnet.zth;
+
+import java.sql.Connection;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.GregorianCalendar;
+import java.util.HashMap;
+
+import ro.teamnet.zth.dao.DepartmentDao;
+import ro.teamnet.zth.dao.EmployeeDao;
+import ro.teamnet.zth.dao.JobDao;
+import ro.teamnet.zth.domain.Department;
+import ro.teamnet.zth.domain.Employee;
+import ro.teamnet.zth.domain.Job;
+import ro.teamnet.zth.utils.DatabaseManager;
+
+/**
+ * Hello world!
+ *
+ */
+public class App
+{
+
+ private static final String USERNAME = "ZTH_01";
+ private static final String PASSWORD = "passw0rd";
+ private static final String URL = "jdbc:oracle:thin:@10.6.33.102:1521:orcl";
+ public static void main( String[] args )
+ {
+ System.out.println( "Hello World!" );
+
+ Connection con = null;
+
+ HashMap hashMap = new HashMap();
+ hashMap.put("id", "number primary key");
+ hashMap.put("first_name", "varchar2(40) not null");
+ hashMap.put("last_name", "varchar2(40) not null");
+ hashMap.put("phone_number", "varchar2(35)");
+
+// con = DatabaseManager.getConnection(USERNAME,PASSWORD);
+ con = DatabaseManager.getConnection(USERNAME,PASSWORD,URL);
+// DatabaseManager.checkConnection(con);
+// DatabaseManager.getFirstRow(con);
+// DatabaseManager.create(con,"test_jdbc",hashMap);
+// DatabaseManager.drop(con,"test_jdbc");
+
+// JobDao job = new JobDao();
+// ArrayList arrayList = job.getAllJobs(con);
+// System.out.println(arrayList.toString());
+
+// DepartmentDao depDao = new DepartmentDao();
+// ArrayList arrayList = depDao.getAllDepartments(con);
+// Department dep = depDao.getDepartmentById(con,50);
+// System.out.println(dep.toString());
+// System.out.println(arrayList.toString());
+
+// EmployeeDao employeeDao = new EmployeeDao();
+// ArrayList arrayList = employeeDao.getAllEmployees(con);
+// Employee employee = employeeDao.getEmployeeById(con,203);
+// System.out.println(employee.toString());
+// System.out.println(arrayList.toString());
+
+// Job job = new Job();
+// Department dep = new Department();
+// Employee manager = new Employee();
+// Date date = new Date(1346524199000l);
+// manager.setEmployeeId(100L);
+// dep.setDepartmentId(150L);
+// job.setJobId("SA_REP");
+// Employee employee = new Employee();
+// employee.setEmployeeId(900L);
+// employee.setFirstName("Vlad");
+// employee.setLastName("Bulimac");
+// employee.setEmail("buli.vlad@yahoo.com");
+// employee.setPhoneNmber("0742387589");
+// employee.setHireDate(date);
+// employee.setJob(job);
+// employee.setSalary(12000.2);
+// employee.setCommisionPoints(20.2);
+// employee.setDepartment(dep);
+// employee.setManager(manager);
+//
+// EmployeeDao emp = new EmployeeDao();
+// emp.saveEmployee(employee,con);
+
+ DatabaseManager.closeConnecction(con);
+
+ }
+}
diff --git a/ exercises/zth-app/src/main/java/ro/teamnet/zth/dao/DepartmentDao.java b/ exercises/zth-app/src/main/java/ro/teamnet/zth/dao/DepartmentDao.java
new file mode 100644
index 0000000..0c54258
--- /dev/null
+++ b/ exercises/zth-app/src/main/java/ro/teamnet/zth/dao/DepartmentDao.java
@@ -0,0 +1,149 @@
+package ro.teamnet.zth.dao;
+
+import ro.teamnet.zth.domain.Department;
+import ro.teamnet.zth.domain.Job;
+import ro.teamnet.zth.utils.ResultSetToPojoConvert;
+
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.HashMap;
+
+/**
+ * Created by Buli on 04.11.2014.
+ */
+public class DepartmentDao {
+
+ public ArrayList getAllDepartments(Connection con) {
+ PreparedStatement stmt = null;
+ ResultSet rs = null;
+ String selectAllFromTableString = "Select * from Departments";
+ try {
+ stmt = con.prepareStatement(selectAllFromTableString);
+ rs = stmt.executeQuery();
+ return ResultSetToPojoConvert.convertToDepartment(rs, con);
+ } catch (SQLException e) {
+ e.printStackTrace();
+ } finally {
+ try {
+ stmt.close();
+ rs.close();
+ } catch (SQLException e) {
+ e.printStackTrace();
+ }
+ }
+ return new ArrayList();
+ }
+
+ public Department getDepartmentById(Connection con, int id) {
+ String selectAllFromTableString = "Select * from Departments where department_id = ?";
+ PreparedStatement stmt = null;
+ ResultSet rs = null;
+ ArrayList departments = null;
+ try {
+ stmt = con.prepareStatement(selectAllFromTableString);
+ stmt.setInt(1, id);
+ rs = stmt.executeQuery();
+ departments = ResultSetToPojoConvert.convertToDepartment(rs, con);
+ } catch (SQLException e) {
+ e.printStackTrace();
+ } finally {
+ try {
+ stmt.close();
+ rs.close();
+ } catch (SQLException e) {
+ e.printStackTrace();
+ }
+ }
+ return departments.size() > 0 ? departments.get(0) : null;
+ }
+
+ public void saveDepartment(Department department, Connection con) {
+ HashMap insertIntoTableDepartments = new HashMap();
+ String tableName = "departments";
+
+ insertIntoTableDepartments.put("department_id", department.getDepartmentId().toString());
+ insertIntoTableDepartments.put("department_name", department.getDepartmentName());
+ insertIntoTableDepartments.put("department_location", department.getLocation().getLocationId().toString());
+
+ PreparedStatement stmt;
+ try {
+ stmt = con.prepareStatement("");
+ String createTableString = "INSERT INTO " + tableName + " ( ";
+ StringBuilder sqlStatement = new StringBuilder();
+ sqlStatement.append(createTableString);
+ Integer valuesCount = insertIntoTableDepartments.keySet().size();
+
+ for (String value : insertIntoTableDepartments.keySet()) {
+ valuesCount--;
+ String columnName = value + (valuesCount != 0 ? " , " : " ) ");
+ sqlStatement.append(columnName);
+ }
+
+ sqlStatement.append(" VALUES ( '");
+ valuesCount = insertIntoTableDepartments.keySet().size();
+
+ for (String valueName : insertIntoTableDepartments.keySet()) {
+ valuesCount--;
+ String columnString = insertIntoTableDepartments.get(valueName) + (valuesCount != 0 ? "' , '" : "')");
+ sqlStatement.append(columnString);
+ }
+
+ stmt.executeQuery(sqlStatement.toString());
+ stmt.close();
+ System.out.println("Inserted into table " + tableName + "...");
+
+ } catch (SQLException e) {
+ e.printStackTrace();
+ }
+ }
+
+ public void updateDepartment(Department department, Connection con){
+ HashMap insertIntoTableDepartments = new HashMap();
+ String tableName = "departments";
+
+ insertIntoTableDepartments.put("department_id", department.getDepartmentId().toString());
+ insertIntoTableDepartments.put("department_name", department.getDepartmentName());
+ insertIntoTableDepartments.put("department_location", department.getLocation().getLocationId().toString());
+
+ PreparedStatement stmt;
+
+ try {
+ stmt = con.prepareStatement("");
+ String updateTableString = "UPDATE " + tableName + " SET ";
+ StringBuilder sqlStatement = new StringBuilder();
+ sqlStatement.append(updateTableString);
+ Integer columnsCount = insertIntoTableDepartments.keySet().size();
+
+ for(String columnName : insertIntoTableDepartments.keySet()){
+ columnsCount --;
+ String columnString = columnName + " = '" + insertIntoTableDepartments.get(columnName) + (columnsCount != 0 ? "' , " : "' ");
+ sqlStatement.append(columnString);
+ }
+
+ sqlStatement.append("WHERE department_id = " + department.getDepartmentId());
+ stmt.executeQuery(sqlStatement.toString());
+ stmt.close();
+ System.out.println("Created table " + tableName + " in database...");
+ } catch (SQLException e) {
+ e.printStackTrace();
+ }
+ }
+
+ public void deleteDepartment(Department department, Connection con){
+ PreparedStatement stmt;
+ String tableName = "departments";
+ try {
+ stmt = con.prepareStatement("");
+ String deleteStatement = "DELETE FROM " + tableName + " WHERE department_id = " + department.getDepartmentId();
+ stmt.executeUpdate(deleteStatement);
+ stmt.close();
+ System.out.println("Dropped table " + tableName + " from database...");
+ } catch (SQLException e) {
+ e.printStackTrace();
+ }
+ }
+
+}
diff --git a/ exercises/zth-app/src/main/java/ro/teamnet/zth/dao/EmployeeDao.java b/ exercises/zth-app/src/main/java/ro/teamnet/zth/dao/EmployeeDao.java
new file mode 100644
index 0000000..b3c08fa
--- /dev/null
+++ b/ exercises/zth-app/src/main/java/ro/teamnet/zth/dao/EmployeeDao.java
@@ -0,0 +1,181 @@
+package ro.teamnet.zth.dao;
+
+import ro.teamnet.zth.domain.Employee;
+import ro.teamnet.zth.utils.ResultSetToPojoConvert;
+
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.HashMap;
+
+/**
+ * Created by Buli on 04.11.2014.
+ */
+public class EmployeeDao {
+
+ public ArrayList getAllEmployees(Connection con) {
+ PreparedStatement stmt = null;
+ ResultSet rs = null;
+ String selectAllFromTableString = "Select * from employees";
+ try {
+ stmt = con.prepareStatement(selectAllFromTableString);
+ stmt.setMaxRows(5);
+ rs = stmt.executeQuery();
+ return ResultSetToPojoConvert.convertToEmployee(rs, con);
+ } catch (SQLException e) {
+ e.printStackTrace();
+ } finally {
+ try {
+ stmt.close();
+ rs.close();
+ } catch (SQLException e) {
+ e.printStackTrace();
+ }
+ }
+ return new ArrayList();
+ }
+
+ public Employee getEmployeeById(Connection con, int id) {
+ String selectAllFromTableString = "Select * from employees where employee_id = ?";
+ PreparedStatement stmt = null;
+ ResultSet rs = null;
+ ArrayList employees = null;
+ try {
+ stmt = con.prepareStatement(selectAllFromTableString);
+ stmt.setInt(1, id);
+ rs = stmt.executeQuery();
+ employees = ResultSetToPojoConvert.convertToEmployee(rs, con);
+ } catch (SQLException e) {
+ e.printStackTrace();
+ } finally {
+ try {
+ stmt.close();
+ rs.close();
+ } catch (SQLException e) {
+ e.printStackTrace();
+ }
+ }
+ return employees.size() > 0 ? employees.get(0) : null;
+ }
+/* insert delete update*/
+
+ public void saveEmployee(Employee employee, Connection con){
+ HashMap insertIntoTableEmployees = new HashMap();
+ String tableName = "employees";
+
+ insertIntoTableEmployees.put("employee_id", employee.getEmployeeId().toString());
+ insertIntoTableEmployees.put("first_name", employee.getFirstName());
+ insertIntoTableEmployees.put("last_name", employee.getLastName());
+ insertIntoTableEmployees.put("email", employee.getEmail());
+ insertIntoTableEmployees.put("phone_number", employee.getPhoneNmber());
+ insertIntoTableEmployees.put("hire_date", "TO_DATE('" + employee.getHireDate().toString() + "','yyyy-mm-dd')");
+ insertIntoTableEmployees.put("job_id",employee.getJob().getJobId().toString());
+ insertIntoTableEmployees.put("salary", employee.getSalary().toString());
+ insertIntoTableEmployees.put("commission_pct", employee.getCommisionPoints().toString());
+ insertIntoTableEmployees.put("manager_id", employee.getManager().getEmployeeId().toString());
+ insertIntoTableEmployees.put("department_id", employee.getDepartment().getDepartmentId().toString());
+
+ PreparedStatement stmt;
+ try {
+
+ String createTableString = "INSERT INTO " + tableName + " ( ";
+ StringBuilder sqlStatement = new StringBuilder();
+ sqlStatement.append(createTableString);
+ Integer valuesCount = insertIntoTableEmployees.keySet().size();
+
+ for(String value : insertIntoTableEmployees.keySet()){
+ valuesCount --;
+ String columnName = value + (valuesCount != 0 ? " , " : " ) ");
+ sqlStatement.append(columnName);
+ }
+
+ sqlStatement.append(" VALUES ( '");
+ valuesCount = insertIntoTableEmployees.keySet().size();
+
+ for(String valueName : insertIntoTableEmployees.keySet()){
+ valuesCount --;
+ String columnString;
+ if (valueName.equals("hire_date")) {
+ columnString = insertIntoTableEmployees.get(valueName) + (valuesCount != 0 ? " , '" : "')");
+ }else if (valueName.equals("phone_number")) {
+ columnString = insertIntoTableEmployees.get(valueName) + (valuesCount != 0 ? "' , " : "')");
+ }else
+ {
+ columnString = insertIntoTableEmployees.get(valueName) + (valuesCount != 0 ? "' , '" : "')");
+ }
+ sqlStatement.append(columnString);
+ }
+ System.out.println(sqlStatement.toString());
+ stmt = con.prepareStatement(sqlStatement.toString());
+ ResultSet rs = stmt.executeQuery();
+ stmt.close();
+ System.out.println("Inserted into table " + tableName + "...");
+
+ } catch (SQLException e) {
+ e.printStackTrace();
+ }
+ }
+
+ public void updateEmployee(Employee employee, Connection con){
+ HashMap insertIntoTableEmployees = new HashMap();
+ String tableName = "employees";
+
+ insertIntoTableEmployees.put("employee_id", employee.getEmployeeId().toString());
+ insertIntoTableEmployees.put("first_name", employee.getFirstName());
+ insertIntoTableEmployees.put("last_name", employee.getLastName());
+ insertIntoTableEmployees.put("email", employee.getEmail());
+ insertIntoTableEmployees.put("phone_number", employee.getPhoneNmber());
+ insertIntoTableEmployees.put("hire_date", "TO_DATE('" + employee.getHireDate().toString() + "','yyyy-mm-dd')");
+ insertIntoTableEmployees.put("job_id",employee.getJob().getJobId().toString());
+ insertIntoTableEmployees.put("salary", employee.getSalary().toString());
+ insertIntoTableEmployees.put("commission_pct", employee.getCommisionPoints().toString());
+ insertIntoTableEmployees.put("manager_id", employee.getManager().getEmployeeId().toString());
+ insertIntoTableEmployees.put("department_id", employee.getDepartment().getDepartmentId().toString());
+
+ PreparedStatement stmt;
+
+ try {
+
+ String updateTableString = "UPDATE " + tableName + " SET ";
+ StringBuilder sqlStatement = new StringBuilder();
+ sqlStatement.append(updateTableString);
+ Integer columnsCount = insertIntoTableEmployees.keySet().size();
+
+ for(String columnName : insertIntoTableEmployees.keySet()){
+ columnsCount --;
+ String columnString;
+ if (columnName.equals("hire_date")) {
+ columnString = columnName + " = " + insertIntoTableEmployees.get(columnName) + (columnsCount != 0 ? " , " : "' ");
+ } else {
+ columnString = columnName + " = '" + insertIntoTableEmployees.get(columnName) + (columnsCount != 0 ? "' , " : "' ");
+ }
+ sqlStatement.append(columnString);
+ }
+
+ sqlStatement.append("WHERE employee_id = " + employee.getEmployeeId());
+ stmt = con.prepareStatement(sqlStatement.toString());
+ stmt.executeQuery();
+ stmt.close();
+ System.out.println("Created table " + tableName + " in database...");
+ } catch (SQLException e) {
+ e.printStackTrace();
+ }
+ }
+
+ public void deleteEmployee(Employee employee, Connection con){
+ PreparedStatement stmt;
+ String tableName = "employees";
+ try {
+
+ String deleteStatement = "DELETE FROM " + tableName + " WHERE employee_id = " + employee.getEmployeeId();
+ stmt = con.prepareStatement(deleteStatement);
+ stmt.executeUpdate();
+ stmt.close();
+ System.out.println("Dropped table " + tableName + " from database...");
+ } catch (SQLException e) {
+ e.printStackTrace();
+ }
+ }
+}
diff --git a/ exercises/zth-app/src/main/java/ro/teamnet/zth/dao/EmployeeViewDao.java b/ exercises/zth-app/src/main/java/ro/teamnet/zth/dao/EmployeeViewDao.java
new file mode 100644
index 0000000..a93caa3
--- /dev/null
+++ b/ exercises/zth-app/src/main/java/ro/teamnet/zth/dao/EmployeeViewDao.java
@@ -0,0 +1,32 @@
+package ro.teamnet.zth.dao;
+
+import ro.teamnet.zth.utils.ResultSetToPojoConvert;
+import ro.teamnet.zth.views.EmployeeView;
+
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.ArrayList;
+
+/**
+ * Created by Buli on 04.11.2014.
+ */
+public class EmployeeViewDao {
+
+ public EmployeeView getEmployeeView(Connection con, Long id){
+ PreparedStatement stmt;
+ ArrayList employeeViews = null;
+ try {
+ stmt = con.prepareStatement("");
+ String query = "SELECT * " + "FROM EMPLOYEE_LIST " + "WHERE employee_id=" + id;
+ ResultSet rs = stmt.executeQuery(query);
+ employeeViews = ResultSetToPojoConvert.convertToEmployeeView(rs,con);
+ stmt.close();
+ } catch (SQLException e) {
+ e.printStackTrace();
+ }
+ return employeeViews.size() > 0 ? employeeViews.get(0) : null;
+ }
+
+}
diff --git a/ exercises/zth-app/src/main/java/ro/teamnet/zth/dao/JobDao.java b/ exercises/zth-app/src/main/java/ro/teamnet/zth/dao/JobDao.java
new file mode 100644
index 0000000..02cb655
--- /dev/null
+++ b/ exercises/zth-app/src/main/java/ro/teamnet/zth/dao/JobDao.java
@@ -0,0 +1,152 @@
+package ro.teamnet.zth.dao;
+
+import ro.teamnet.zth.domain.Employee;
+import ro.teamnet.zth.domain.Job;
+import ro.teamnet.zth.utils.ResultSetToPojoConvert;
+
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.HashMap;
+
+/**
+ * Created by Buli on 04.11.2014.
+ */
+public class JobDao {
+
+ public ArrayList getAllJobs(Connection con) {
+ PreparedStatement stmt = null;
+ ResultSet rs = null;
+ String selectAllFromTableString = "Select job_id, job_title, min_salary, max_salary from Jobs";
+ try {
+ stmt = con.prepareStatement(selectAllFromTableString);
+ stmt.setMaxRows(5);
+ rs = stmt.executeQuery();
+ return ResultSetToPojoConvert.convertToJob(rs, con);
+ } catch (SQLException e) {
+ e.printStackTrace();
+ } finally {
+ try {
+ stmt.close();
+ rs.close();
+ } catch (SQLException e) {
+ e.printStackTrace();
+ }
+ }
+ return new ArrayList();
+ }
+
+ public Job getJobById(Connection con, String id) {
+ String selectAllFromTableString = "Select * from Jobs where job_id = ?";
+ PreparedStatement stmt = null;
+ ResultSet rs = null;
+ ArrayList jobs = null;
+ try {
+ stmt = con.prepareStatement(selectAllFromTableString);
+ stmt.setString(1, id);
+ rs = stmt.executeQuery();
+ jobs = ResultSetToPojoConvert.convertToJob(rs, con);
+ } catch (SQLException e) {
+ e.printStackTrace();
+ } finally {
+ try {
+ stmt.close();
+ rs.close();
+ } catch (SQLException e) {
+ e.printStackTrace();
+ }
+ }
+ return jobs.size() > 0 ? jobs.get(0) : null;
+ }
+
+ public void saveJob(Job job, Connection con) {
+ HashMap insertIntoTableJobs = new HashMap();
+ String tableName = "jobs";
+
+ insertIntoTableJobs.put("job_id", job.getJobId());
+ insertIntoTableJobs.put("job_title", job.getJobTitle());
+ insertIntoTableJobs.put("min_salary", job.getMinSalary().toString());
+ insertIntoTableJobs.put("max_salary", job.getMaxSalary().toString());
+
+ PreparedStatement stmt;
+ try {
+ stmt = con.prepareStatement("");
+ String createTableString = "INSERT INTO " + tableName + " ( ";
+ StringBuilder sqlStatement = new StringBuilder();
+ sqlStatement.append(createTableString);
+ Integer valuesCount = insertIntoTableJobs.keySet().size();
+
+ for (String value : insertIntoTableJobs.keySet()) {
+ valuesCount--;
+ String columnName = value + (valuesCount != 0 ? " , " : " ) ");
+ sqlStatement.append(columnName);
+ }
+
+ sqlStatement.append(" VALUES ( '");
+ valuesCount = insertIntoTableJobs.keySet().size();
+
+ for (String valueName : insertIntoTableJobs.keySet()) {
+ valuesCount--;
+ String columnString = insertIntoTableJobs.get(valueName) + (valuesCount != 0 ? "' , '" : "')");
+ sqlStatement.append(columnString);
+ }
+
+ stmt.executeQuery(sqlStatement.toString());
+ stmt.close();
+ System.out.println("Inserted into table " + tableName + "...");
+
+ } catch (SQLException e) {
+ e.printStackTrace();
+ }
+ }
+
+ public void updateJob(Job job, Connection con){
+ HashMap insertIntoTableJobs = new HashMap();
+ String tableName = "jobs";
+
+ insertIntoTableJobs.put("job_id", job.getJobId());
+ insertIntoTableJobs.put("job_title", job.getJobTitle());
+ insertIntoTableJobs.put("min_salary", job.getMinSalary().toString());
+ insertIntoTableJobs.put("max_salary", job.getMaxSalary().toString());
+
+ PreparedStatement stmt;
+
+ try {
+ stmt = con.prepareStatement("");
+ String updateTableString = "UPDATE " + tableName + " SET ";
+ StringBuilder sqlStatement = new StringBuilder();
+ sqlStatement.append(updateTableString);
+ Integer columnsCount = insertIntoTableJobs.keySet().size();
+
+ for(String columnName : insertIntoTableJobs.keySet()){
+ columnsCount --;
+ String columnString = columnName + " = '" + insertIntoTableJobs.get(columnName) + (columnsCount != 0 ? "' , " : "' ");
+ sqlStatement.append(columnString);
+ }
+
+ sqlStatement.append("WHERE job_id = " + job.getJobId());
+ stmt.executeQuery(sqlStatement.toString());
+ stmt.close();
+ System.out.println("Created table " + tableName + " in database...");
+ } catch (SQLException e) {
+ e.printStackTrace();
+ }
+ }
+
+ public void deleteJob(Job job, Connection con){
+ PreparedStatement stmt;
+ String tableName = "jobs";
+ try {
+ stmt = con.prepareStatement("");
+ String deleteStatement = "DELETE FROM " + tableName + " WHERE job_id = " + job.getJobId();
+ stmt.executeUpdate(deleteStatement);
+ stmt.close();
+ System.out.println("Dropped table " + tableName + " from database...");
+ } catch (SQLException e) {
+ e.printStackTrace();
+ }
+ }
+
+}
diff --git a/ exercises/zth-app/src/main/java/ro/teamnet/zth/dao/LocationDao.java b/ exercises/zth-app/src/main/java/ro/teamnet/zth/dao/LocationDao.java
new file mode 100644
index 0000000..cf436a0
--- /dev/null
+++ b/ exercises/zth-app/src/main/java/ro/teamnet/zth/dao/LocationDao.java
@@ -0,0 +1,154 @@
+package ro.teamnet.zth.dao;
+
+import ro.teamnet.zth.domain.Employee;
+import ro.teamnet.zth.domain.Location;
+import ro.teamnet.zth.utils.ResultSetToPojoConvert;
+
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.HashMap;
+
+/**
+ * Created by Buli on 11/9/2014.
+ */
+public class LocationDao {
+
+ public ArrayList getAllLocations(Connection con){
+ PreparedStatement stmt = null;
+ ResultSet rs = null;
+ String selectAllFromTableString = "Select * from locations";
+ try {
+ stmt = con.prepareStatement(selectAllFromTableString);
+ stmt.setMaxRows(5);
+ rs = stmt.executeQuery();
+ return ResultSetToPojoConvert.convertToLocation(rs, con);
+ } catch (SQLException e) {
+ e.printStackTrace();
+ } finally {
+ try {
+ stmt.close();
+ rs.close();
+ } catch (SQLException e) {
+ e.printStackTrace();
+ }
+ }
+ return new ArrayList();
+ }
+
+ public Location getLocationById(Connection con, int id) {
+ String selectAllFromTableString = "Select * from locations where location_id = ?";
+ PreparedStatement stmt = null;
+ ResultSet rs = null;
+ ArrayList location = null;
+ try {
+ stmt = con.prepareStatement(selectAllFromTableString);
+ stmt.setInt(1, id);
+ rs = stmt.executeQuery();
+ location = ResultSetToPojoConvert.convertToLocation(rs, con);
+ } catch (SQLException e) {
+ e.printStackTrace();
+ } finally {
+ try {
+ stmt.close();
+ rs.close();
+ } catch (SQLException e) {
+ e.printStackTrace();
+ }
+ }
+ return location.size() > 0 ? location.get(0) : null;
+ }
+
+ public void saveLocation(Location location, Connection con){
+ HashMap insertIntoTablelocation = new HashMap();
+ String tableName = "locations";
+
+ insertIntoTablelocation.put("location_id",location.getLocationId().toString());
+ insertIntoTablelocation.put("street_address",location.getStreetAdress().toString());
+ insertIntoTablelocation.put("postal_code",location.getPostalCode().toString());
+ insertIntoTablelocation.put("city",location.getCity().toString());
+ insertIntoTablelocation.put("state_province",location.getStateProvince().toString());
+
+ PreparedStatement stmt;
+ try {
+ stmt = con.prepareStatement("");
+ String createTableString = "INSERT INTO " + tableName + " ( ";
+ StringBuilder sqlStatement = new StringBuilder();
+ sqlStatement.append(createTableString);
+ Integer valuesCount = insertIntoTablelocation.keySet().size();
+
+ for(String value : insertIntoTablelocation.keySet()){
+ valuesCount --;
+ String columnName = value + (valuesCount != 0 ? " , " : " ) ");
+ sqlStatement.append(columnName);
+ }
+
+ sqlStatement.append(" VALUES ( '");
+ valuesCount = insertIntoTablelocation.keySet().size();
+
+ for(String valueName : insertIntoTablelocation.keySet()){
+ valuesCount --;
+ String columnString = insertIntoTablelocation.get(valueName) + (valuesCount != 0 ? "' , '" : "')");
+ sqlStatement.append(columnString);
+ }
+
+ stmt.executeQuery(sqlStatement.toString());
+ stmt.close();
+ System.out.println("Inserted into table " + tableName + "...");
+
+ } catch (SQLException e) {
+ e.printStackTrace();
+ }
+ }
+
+ public void updateLocation(Location location, Connection con){
+ HashMap insertIntoTablelocation = new HashMap();
+ String tableName = "locations";
+
+ insertIntoTablelocation.put("location_id",location.getLocationId().toString());
+ insertIntoTablelocation.put("street_address",location.getStreetAdress().toString());
+ insertIntoTablelocation.put("postal_code",location.getPostalCode().toString());
+ insertIntoTablelocation.put("city",location.getCity().toString());
+ insertIntoTablelocation.put("state_province",location.getStateProvince().toString());
+
+ PreparedStatement stmt;
+
+ try {
+ stmt = con.prepareStatement("");
+ String updateTableString = "UPDATE " + tableName + " SET ";
+ StringBuilder sqlStatement = new StringBuilder();
+ sqlStatement.append(updateTableString);
+ Integer columnsCount = insertIntoTablelocation.keySet().size();
+
+ for(String columnName : insertIntoTablelocation.keySet()){
+ columnsCount --;
+ String columnString = columnName + " = '" + insertIntoTablelocation.get(columnName) + (columnsCount != 0 ? "' , " : "' ");
+ sqlStatement.append(columnString);
+ }
+
+ sqlStatement.append("WHERE location_id = " + location.getLocationId());
+ stmt.executeQuery(sqlStatement.toString());
+ stmt.close();
+ System.out.println("Created table " + tableName + " in database...");
+ } catch (SQLException e) {
+ e.printStackTrace();
+ }
+ }
+
+ public void deleteLocation(Location location, Connection con){
+ PreparedStatement stmt;
+ String tableName = "location";
+ try {
+ stmt = con.prepareStatement("");
+ String deleteStatement = "DELETE FROM " + tableName + " WHERE location_id = " + location.getLocationId();
+ stmt.executeUpdate(deleteStatement);
+ stmt.close();
+ System.out.println("Dropped table " + tableName + " from database...");
+ } catch (SQLException e) {
+ e.printStackTrace();
+ }
+ }
+
+}
diff --git a/ exercises/zth-app/src/main/java/ro/teamnet/zth/domain/Department.java b/ exercises/zth-app/src/main/java/ro/teamnet/zth/domain/Department.java
new file mode 100644
index 0000000..d888288
--- /dev/null
+++ b/ exercises/zth-app/src/main/java/ro/teamnet/zth/domain/Department.java
@@ -0,0 +1,43 @@
+package ro.teamnet.zth.domain;
+
+/**
+ * Created by Buli on 04.11.2014.
+ */
+public class Department {
+
+ private Long departmentId;
+ private String departmentName;
+ private Location location;
+
+ public Location getLocation() {
+ return location;
+ }
+
+ public void setLocation(Location location) {
+ this.location = location;
+ }
+
+ public Long getDepartmentId() {
+ return departmentId;
+ }
+
+ public void setDepartmentId(Long departmentId) {
+ this.departmentId = departmentId;
+ }
+
+ public String getDepartmentName() {
+ return departmentName;
+ }
+
+ public void setDepartmentName(String departmentName) {
+ this.departmentName = departmentName;
+ }
+
+ @Override
+ public String toString() {
+ return "Department{" +
+ "departmentId=" + departmentId +
+ ", departmentName='" + departmentName + '\'' +
+ '}' + "\n";
+ }
+}
diff --git a/ exercises/zth-app/src/main/java/ro/teamnet/zth/domain/Employee.java b/ exercises/zth-app/src/main/java/ro/teamnet/zth/domain/Employee.java
new file mode 100644
index 0000000..af0b1df
--- /dev/null
+++ b/ exercises/zth-app/src/main/java/ro/teamnet/zth/domain/Employee.java
@@ -0,0 +1,126 @@
+package ro.teamnet.zth.domain;
+
+import java.util.Date;
+
+/**
+ * Created by Buli on 04.11.2014.
+ */
+public class Employee {
+
+ private Long employeeId;
+ private String firstName;
+ private String lastName;
+ private Employee manager;
+ private String email;
+ private Date hireDate;
+ private Double salary;
+ private Double commisionPoints;
+ private String phoneNmber;
+ private Job job;
+ private Department department;
+
+ public Long getEmployeeId() {
+ return employeeId;
+ }
+
+ public void setEmployeeId(Long employeeId) {
+ this.employeeId = employeeId;
+ }
+
+ public String getFirstName() {
+ return firstName;
+ }
+
+ public void setFirstName(String firstName) {
+ this.firstName = firstName;
+ }
+
+ public String getLastName() {
+ return lastName;
+ }
+
+ public void setLastName(String lastName) {
+ this.lastName = lastName;
+ }
+
+ public Employee getManager() {
+ return manager;
+ }
+
+ public void setManager(Employee manager) {
+ this.manager = manager;
+ }
+
+ public String getEmail() {
+ return email;
+ }
+
+ public void setEmail(String email) {
+ this.email = email;
+ }
+
+ public Date getHireDate() {
+ return hireDate;
+ }
+
+ public void setHireDate(Date hireDate) {
+ this.hireDate = hireDate;
+ }
+
+ public Double getSalary() {
+ return salary;
+ }
+
+ public void setSalary(Double salary) {
+ this.salary = salary;
+ }
+
+ public Double getCommisionPoints() {
+ return commisionPoints;
+ }
+
+ public void setCommisionPoints(Double commisionPoints) {
+ this.commisionPoints = commisionPoints;
+ }
+
+ public String getPhoneNmber() {
+ return phoneNmber;
+ }
+
+ public void setPhoneNmber(String phoneNmber) {
+ this.phoneNmber = phoneNmber;
+ }
+
+ public Job getJob() {
+ return job;
+ }
+
+ public void setJob(Job job) {
+ this.job = job;
+ }
+
+ public Department getDepartment() {
+ return department;
+ }
+
+ public void setDepartment(Department department) {
+ this.department = department;
+ }
+
+ @Override
+ public String toString() {
+ return "Employee{" +
+ "employeeId=" + employeeId +
+ ", firstName='" + firstName + '\'' +
+ ", lastName='" + lastName + '\'' +
+ ", manager=" + manager +
+ ", email='" + email + '\'' +
+ ", hireDate=" + hireDate +
+ ", salary=" + salary +
+ ", commisionPoints=" + commisionPoints +
+ ", phoneNmber='" + phoneNmber + '\'' +
+ ", job=" + job +
+ ", department=" + department +
+ '}';
+ }
+}
diff --git a/ exercises/zth-app/src/main/java/ro/teamnet/zth/domain/Job.java b/ exercises/zth-app/src/main/java/ro/teamnet/zth/domain/Job.java
new file mode 100644
index 0000000..dac80f6
--- /dev/null
+++ b/ exercises/zth-app/src/main/java/ro/teamnet/zth/domain/Job.java
@@ -0,0 +1,54 @@
+package ro.teamnet.zth.domain;
+
+/**
+ * Created by Buli on 04.11.2014.
+ */
+public class Job {
+
+ private String jobId;
+ private String jobTitle;
+ private Double minSalary;
+ private Double maxSalary;
+
+ public String getJobId() {
+ return jobId;
+ }
+
+ public void setJobId(String jobId) {
+ this.jobId = jobId;
+ }
+
+ public String getJobTitle() {
+ return jobTitle;
+ }
+
+ public void setJobTitle(String jobTitle) {
+ this.jobTitle = jobTitle;
+ }
+
+ public Double getMinSalary() {
+ return minSalary;
+ }
+
+ public void setMinSalary(Double minSalary) {
+ this.minSalary = minSalary;
+ }
+
+ public Double getMaxSalary() {
+ return maxSalary;
+ }
+
+ public void setMaxSalary(Double maxSalary) {
+ this.maxSalary = maxSalary;
+ }
+
+ @Override
+ public String toString() {
+ return "Job{" +
+ "jobId='" + jobId + '\'' +
+ ", jobTitle='" + jobTitle + '\'' +
+ ", minSalary=" + minSalary +
+ ", maxSalary=" + maxSalary +
+ "} \n";
+ }
+}
diff --git a/ exercises/zth-app/src/main/java/ro/teamnet/zth/domain/Location.java b/ exercises/zth-app/src/main/java/ro/teamnet/zth/domain/Location.java
new file mode 100644
index 0000000..1217c50
--- /dev/null
+++ b/ exercises/zth-app/src/main/java/ro/teamnet/zth/domain/Location.java
@@ -0,0 +1,53 @@
+package ro.teamnet.zth.domain;
+
+/**
+ * Created by Buli on 11/9/2014.
+ */
+public class Location {
+
+ private Long locationId;
+ private String streetAdress;
+ private String postalCode;
+ private String city;
+ private String stateProvince;
+
+ public Long getLocationId() {
+ return locationId;
+ }
+
+ public void setLocationId(Long locationId) {
+ this.locationId = locationId;
+ }
+
+ public String getStreetAdress() {
+ return streetAdress;
+ }
+
+ public void setStreetAdress(String streetAdress) {
+ this.streetAdress = streetAdress;
+ }
+
+ public String getPostalCode() {
+ return postalCode;
+ }
+
+ public void setPostalCode(String postalCode) {
+ this.postalCode = postalCode;
+ }
+
+ public String getCity() {
+ return city;
+ }
+
+ public void setCity(String city) {
+ this.city = city;
+ }
+
+ public String getStateProvince() {
+ return stateProvince;
+ }
+
+ public void setStateProvince(String stateProvince) {
+ this.stateProvince = stateProvince;
+ }
+}
diff --git a/ exercises/zth-app/src/main/java/ro/teamnet/zth/utils/DatabaseManager.java b/ exercises/zth-app/src/main/java/ro/teamnet/zth/utils/DatabaseManager.java
new file mode 100644
index 0000000..11de3a3
--- /dev/null
+++ b/ exercises/zth-app/src/main/java/ro/teamnet/zth/utils/DatabaseManager.java
@@ -0,0 +1,179 @@
+package ro.teamnet.zth.utils;
+
+import oracle.jdbc.pool.OracleDataSource;
+
+import javax.sql.DataSource;
+import javax.swing.plaf.nimbus.State;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.PrintWriter;
+import java.sql.*;
+import java.util.HashMap;
+import java.util.Properties;
+import java.util.logging.Logger;
+
+/**
+ * Created by Buli on 04.11.2014.
+ */
+public class DatabaseManager {
+
+ public static Connection getConnection(String username, String password) {
+
+ Properties info = new Properties();
+ info.put("ORACLE_DB_USERNAME", username);
+ info.put("ORACLE_DB_PASSWORD", password);
+ info.put("ORACLE_DB_URL","jdbc:oracle:thin:@10.6.33.102:1521:orcl");
+
+ Connection con = null;
+
+ try {
+ OracleDataSource ds = new OracleDataSource();
+ ds.setURL(info.getProperty("ORACLE_DB_URL"));
+ ds.setUser(info.getProperty("ORACLE_DB_USERNAME"));
+ ds.setPassword(info.getProperty("ORACLE_DB_PASSWORD"));
+ con = ds.getConnection();
+ } catch (SQLException e) {
+ e.printStackTrace();
+ }
+
+ return con;
+ }
+
+ public static Connection getConnection(String username, String password, String URL) {
+
+ Properties info = new Properties();
+ info.put("ORACLE_DB_USERNAME", username);
+ info.put("ORACLE_DB_PASSWORD", password);
+ info.put("ORACLE_DB_URL",URL);
+
+ Connection con = null;
+
+ try {
+ OracleDataSource ds = new OracleDataSource();
+ ds.setURL(info.getProperty("ORACLE_DB_URL"));
+ ds.setUser(info.getProperty("ORACLE_DB_USERNAME"));
+ ds.setPassword(info.getProperty("ORACLE_DB_PASSWORD"));
+ con = ds.getConnection();
+ } catch (SQLException e) {
+ e.printStackTrace();
+ }
+
+ return con;
+ }
+
+ public static void checkConnection(Connection con) {
+
+ PreparedStatement statement = null;
+ try {
+ statement = con.prepareStatement("SELECT SYSDATE from DUAL");
+ ResultSet rs = null;
+ rs = statement.executeQuery();
+
+ if (rs.next()) {
+ Date currentDate = rs.getDate(1);
+ System.out.println("Current date from oracle is : " + currentDate);
+ }
+ rs.close();
+ } catch (SQLException e) {
+ e.printStackTrace();
+ } finally {
+ try {
+ statement.close();
+ } catch (SQLException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+
+ public static void getFirstRow(Connection con) {
+
+ PreparedStatement statement = null;
+ try {
+ String sqlStatement = "";
+ ResultSet rs = null;
+ statement = con.prepareStatement("SELECT * from EMPLOYEES where employee_id = ?");
+ statement.setInt(1,100);
+ rs = statement.executeQuery();
+
+ if (rs.next()) {
+ System.out.println("Current date from oracle is : " + rs.getString(1) + "");
+ }
+ rs.close();
+ } catch (SQLException e) {
+ e.printStackTrace();
+ } finally {
+ try {
+ statement.close();
+ } catch (SQLException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+
+ public static void create(Connection con, String tableName, HashMap columnData) {
+
+ PreparedStatement stat = null;
+
+ try {
+ String createTableString = "CREATE TABLE " + tableName + " ( ";
+ StringBuilder sqlStatement = new StringBuilder();
+ sqlStatement.append(createTableString);
+ Integer columnsCount = columnData.keySet().size();
+
+ for(String columnName : columnData.keySet()){
+ columnsCount --;
+ String columnString = columnName + " " + columnData.get(columnName) + (columnsCount != 0 ? " , " : ")");
+ sqlStatement.append(columnString);
+ }
+
+ stat = con.prepareStatement(sqlStatement.toString());
+ stat.executeQuery();
+
+ System.out.println("Created table " + tableName + " in database...");
+
+ } catch (SQLException e) {
+ e.printStackTrace();
+ }
+ finally {
+ try {
+ stat.close();
+ } catch (SQLException e) {
+ e.printStackTrace();
+ }
+ }
+
+
+ }
+
+ public static void drop(Connection con, String tableName) {
+
+ PreparedStatement stmt = null;
+
+ ResultSet rs = null;
+ try {
+ String sqlStatement = "DROP TABLE " + tableName;
+ stmt = con.prepareStatement(sqlStatement);
+ stmt.executeQuery();
+ System.out.println("Droped table " + tableName + "from database...");
+ } catch (SQLException e) {
+ e.printStackTrace();
+ }
+ finally {
+ try {
+ stmt.close();
+ } catch (SQLException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+
+ public static void closeConnecction(Connection con) {
+ try {
+ con.close();
+ } catch (SQLException e) {
+ e.printStackTrace();
+ }
+ }
+
+}
diff --git a/ exercises/zth-app/src/main/java/ro/teamnet/zth/utils/ResultSetToPojoConvert.java b/ exercises/zth-app/src/main/java/ro/teamnet/zth/utils/ResultSetToPojoConvert.java
new file mode 100644
index 0000000..4435b77
--- /dev/null
+++ b/ exercises/zth-app/src/main/java/ro/teamnet/zth/utils/ResultSetToPojoConvert.java
@@ -0,0 +1,99 @@
+package ro.teamnet.zth.utils;
+
+import ro.teamnet.zth.dao.DepartmentDao;
+import ro.teamnet.zth.dao.EmployeeDao;
+import ro.teamnet.zth.dao.JobDao;
+import ro.teamnet.zth.dao.LocationDao;
+import ro.teamnet.zth.domain.Department;
+import ro.teamnet.zth.domain.Employee;
+import ro.teamnet.zth.domain.Job;
+import ro.teamnet.zth.domain.Location;
+import ro.teamnet.zth.views.EmployeeView;
+
+import java.sql.Connection;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.Objects;
+
+/**
+ * Created by Buli on 11/5/2014.
+ */
+public class ResultSetToPojoConvert {
+
+
+
+ public static ArrayList convertToEmployee(ResultSet rs, Connection con) throws SQLException{
+ ArrayList arrayListFromResultSet = new ArrayList();
+ JobDao jobDao = new JobDao();
+ EmployeeDao employeeDao = new EmployeeDao();
+ while(rs.next()){
+ Employee newEmployee = new Employee();
+ newEmployee.setEmployeeId(rs.getLong("employee_id"));
+ newEmployee.setFirstName(rs.getString("first_name"));
+ newEmployee.setLastName(rs.getString("last_name"));
+ newEmployee.setEmail(rs.getString("email"));
+ newEmployee.setHireDate(rs.getDate("hire_date"));
+ newEmployee.setJob(jobDao.getJobById(con,rs.getString("job_id")));
+ newEmployee.setSalary(rs.getDouble("salary"));
+ newEmployee.setCommisionPoints(rs.getDouble("commission_pct"));
+ newEmployee.setManager(employeeDao.getEmployeeById(con,rs.getInt("manager_id")));
+ newEmployee.setDepartment((new DepartmentDao().getDepartmentById(con,rs.getInt("department_id"))));
+ arrayListFromResultSet.add(newEmployee);
+ }
+ return arrayListFromResultSet;
+ }
+
+ public static ArrayList convertToJob(ResultSet rs, Connection con) throws SQLException{
+ ArrayList arrayListFromResultSet = new ArrayList();
+ while(rs.next()){
+ Job newJob = new Job();
+ newJob.setJobId(rs.getString("job_id"));
+ newJob.setJobTitle(rs.getString("job_title"));
+ newJob.setMinSalary(rs.getDouble("min_salary"));
+ newJob.setMaxSalary(rs.getDouble("max_salary"));
+ arrayListFromResultSet.add(newJob);
+ }
+ return arrayListFromResultSet;
+ }
+
+ public static ArrayList convertToDepartment(ResultSet rs, Connection con) throws SQLException{
+ ArrayList arrayListFromResultSet = new ArrayList();
+ LocationDao locationDao = new LocationDao();
+ while (rs.next()){
+ Department department = new Department();
+ department.setDepartmentId(rs.getLong("department_id"));
+ department.setDepartmentName(rs.getString("department_name"));
+ department.setLocation(locationDao.getLocationById(con,rs.getInt("location_id")));
+ arrayListFromResultSet.add(department);
+ }
+ return arrayListFromResultSet;
+ }
+
+ public static ArrayList convertToLocation(ResultSet rs, Connection con) throws SQLException{
+ ArrayList arrayListFromResultSet = new ArrayList();
+ while (rs.next()){
+ Location location = new Location();
+ location.setLocationId(rs.getLong("location_id"));
+ location.setStreetAdress(rs.getString("street_address"));
+ location.setPostalCode(rs.getString("postal_code"));
+ location.setCity(rs.getString("city"));
+ location.setStateProvince(rs.getString("state_province"));
+ arrayListFromResultSet.add(location);
+ }
+ return arrayListFromResultSet;
+ }
+
+ public static ArrayList convertToEmployeeView(ResultSet rs, Connection con) throws SQLException{
+ ArrayList arrayListFromResultSet = new ArrayList();
+ while(rs.next()){
+ EmployeeView employeeView = new EmployeeView();
+ employeeView.setEmployeeId(rs.getLong("employee_id"));
+ employeeView.setFirstName(rs.getString("first_name"));
+ employeeView.setDepartmentName(rs.getString("department_name"));
+ arrayListFromResultSet.add(employeeView);
+ }
+ return arrayListFromResultSet;
+ }
+
+}
diff --git a/ exercises/zth-app/src/main/java/ro/teamnet/zth/views/EmployeeView.java b/ exercises/zth-app/src/main/java/ro/teamnet/zth/views/EmployeeView.java
new file mode 100644
index 0000000..280217c
--- /dev/null
+++ b/ exercises/zth-app/src/main/java/ro/teamnet/zth/views/EmployeeView.java
@@ -0,0 +1,37 @@
+package ro.teamnet.zth.views;
+
+import ro.teamnet.zth.domain.Department;
+
+/**
+ * Created by Buli on 11/9/2014.
+ */
+public class EmployeeView {
+
+ private Long employeeId;
+ private String firstName;
+ private String departmentName;
+
+ public Long getEmployeeId() {
+ return employeeId;
+ }
+
+ public void setEmployeeId(Long employeeId) {
+ this.employeeId = employeeId;
+ }
+
+ public String getFirstName() {
+ return firstName;
+ }
+
+ public void setFirstName(String firstName) {
+ this.firstName = firstName;
+ }
+
+ public String getDepartmentName() {
+ return departmentName;
+ }
+
+ public void setDepartmentName(String departmentName) {
+ this.departmentName = departmentName;
+ }
+}
diff --git a/ exercises/zth-app/src/test/java/ro/teamnet/zth/AppTest.java b/ exercises/zth-app/src/test/java/ro/teamnet/zth/AppTest.java
new file mode 100644
index 0000000..3f5a4ca
--- /dev/null
+++ b/ exercises/zth-app/src/test/java/ro/teamnet/zth/AppTest.java
@@ -0,0 +1,38 @@
+package ro.teamnet.zth;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+/**
+ * Unit test for simple App.
+ */
+public class AppTest
+ extends TestCase
+{
+ /**
+ * Create the test case
+ *
+ * @param testName name of the test case
+ */
+ public AppTest( String testName )
+ {
+ super( testName );
+ }
+
+ /**
+ * @return the suite of tests being tested
+ */
+ public static Test suite()
+ {
+ return new TestSuite( AppTest.class );
+ }
+
+ /**
+ * Rigourous Test :-)
+ */
+ public void testApp()
+ {
+ assertTrue( true );
+ }
+}
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..8d6340a
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,5 @@
+.idea
+.iml
+*.iml
+
+*.class
\ No newline at end of file
diff --git a/workshops/SQL/Thumbs.db b/workshops/SQL/Thumbs.db
new file mode 100644
index 0000000..c9e0d57
Binary files /dev/null and b/workshops/SQL/Thumbs.db differ
diff --git a/workshops/Thumbs.db b/workshops/Thumbs.db
new file mode 100644
index 0000000..52bf308
Binary files /dev/null and b/workshops/Thumbs.db differ