Tariq Hook 7 gadus atpakaļ
vecāks
revīzija
1aa2a8f534

+ 147
- 0
.gitignore Parādīt failu

@@ -0,0 +1,147 @@
1
+# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm
2
+# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
3
+
4
+# User-specific stuff:
5
+.idea/**/workspace.xml
6
+.idea/**/tasks.xml
7
+.idea/dictionaries
8
+
9
+# Sensitive or high-churn files:
10
+.idea/**/dataSources/
11
+.idea/**/dataSources.ids
12
+.idea/**/dataSources.xml
13
+.idea/**/dataSources.local.xml
14
+.idea/**/sqlDataSources.xml
15
+.idea/**/dynamic.xml
16
+.idea/**/uiDesigner.xml
17
+
18
+# Gradle:
19
+.idea/**/gradle.xml
20
+.idea/**/libraries
21
+
22
+# CMake
23
+cmake-build-debug/
24
+
25
+# Mongo Explorer plugin:
26
+.idea/**/mongoSettings.xml
27
+
28
+## File-based project format:
29
+*.iws
30
+
31
+## Plugin-specific files:
32
+
33
+# IntelliJ
34
+/out/
35
+
36
+# mpeltonen/sbt-idea plugin
37
+.idea_modules/
38
+# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm
39
+# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
40
+
41
+# User-specific stuff:
42
+*.iml
43
+.idea/**
44
+.idea/**/workspace.xml
45
+.idea/**/tasks.xml
46
+.idea/dictionaries
47
+
48
+# Sensitive or high-churn files:
49
+.idea/**/dataSources/
50
+.idea/**/dataSources.ids
51
+.idea/**/dataSources.xml
52
+.idea/**/dataSources.local.xml
53
+.idea/**/sqlDataSources.xml
54
+.idea/**/dynamic.xml
55
+.idea/**/uiDesigner.xml
56
+
57
+# Gradle:
58
+.idea/**/gradle.xml
59
+.idea/**/libraries
60
+
61
+# CMake
62
+cmake-build-debug/
63
+
64
+# Mongo Explorer plugin:
65
+.idea/**/mongoSettings.xml
66
+
67
+## File-based project format:
68
+*.iws
69
+
70
+## Plugin-specific files:
71
+
72
+# IntelliJ
73
+/out/
74
+
75
+# mpeltonen/sbt-idea plugin
76
+.idea_modules/
77
+
78
+# JIRA plugin
79
+atlassian-ide-plugin.xml
80
+
81
+# Cursive Clojure plugin
82
+.idea/replstate.xml
83
+
84
+# Crashlytics plugin (for Android Studio and IntelliJ)
85
+com_crashlytics_export_strings.xml
86
+crashlytics.properties
87
+crashlytics-build.properties
88
+fabric.properties# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm
89
+                 # Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
90
+
91
+                 # User-specific stuff:
92
+                 .idea/**/workspace.xml
93
+                 .idea/**/tasks.xml
94
+                 .idea/dictionaries
95
+
96
+                 # Sensitive or high-churn files:
97
+                 .idea/**/dataSources/
98
+                 .idea/**/dataSources.ids
99
+                 .idea/**/dataSources.xml
100
+                 .idea/**/dataSources.local.xml
101
+                 .idea/**/sqlDataSources.xml
102
+                 .idea/**/dynamic.xml
103
+                 .idea/**/uiDesigner.xml
104
+
105
+                 # Gradle:
106
+                 .idea/**/gradle.xml
107
+                 .idea/**/libraries
108
+
109
+                 # CMake
110
+                 cmake-build-debug/
111
+
112
+                 # Mongo Explorer plugin:
113
+                 .idea/**/mongoSettings.xml
114
+
115
+                 ## File-based project format:
116
+                 *.iws
117
+
118
+                 ## Plugin-specific files:
119
+
120
+                 # IntelliJ
121
+                 /out/
122
+
123
+                 # mpeltonen/sbt-idea plugin
124
+                 .idea_modules/
125
+
126
+                 # JIRA plugin
127
+                 atlassian-ide-plugin.xml
128
+
129
+                 # Cursive Clojure plugin
130
+                 .idea/replstate.xml
131
+
132
+                 # Crashlytics plugin (for Android Studio and IntelliJ)
133
+                 com_crashlytics_export_strings.xml
134
+                 crashlytics.properties
135
+                 crashlytics-build.properties
136
+                 fabric.properties
137
+# JIRA plugin
138
+atlassian-ide-plugin.xml
139
+
140
+# Cursive Clojure plugin
141
+.idea/replstate.xml
142
+
143
+# Crashlytics plugin (for Android Studio and IntelliJ)
144
+com_crashlytics_export_strings.xml
145
+crashlytics.properties
146
+crashlytics-build.properties
147
+fabric.properties

+ 52
- 0
README.md Parādīt failu

@@ -1 +1,53 @@
1 1
 # ZCW-MicroLabs-Loops
2
+
3
+##1) 1 to 10
4
+In the class **Numbers**, complete the method called **oneToTen()** so that it returns a string of the numbers 1 to 10. The Unit Test is provided for you.
5
+
6
+###Example<br>
7
+1: oneToTen()<br>
2: *** Output ***<br>
3: 1<br>
4: 2<br>
5: 3<br>
6: 4<br>
7: 5<br>
8: 6<br>
9: 7<br>
10: 8<br>
11: 9<br>
12: 10<br>
8
+
## 2) Odd Numbers
In the class **Numbers**, complete the method called **oddNumbers()** so that it returns a string of the positive odd numbers less than 20. The Unit Test is not provided for you, you must complete it.
9
+
10
+###Example<br>
11
+1: oddNumbers()<br>
2: *** Output *** <br>
3: 1<br>
4: 3<br>
5: 5<br>
6: 7<br>
7: 9<br>
8: 11<br>
9: 13<br>
10: 15<br>
11: 17<br>
12: 19<br>
12
+
## 3) Square Numbers
In the class **Numbers**, complete the method called **squares()** so that it returns a string of the square numbers up to 100. The Unit Test is not provided for you, you must complete it.
13
+
###Example<br>
14
+1: squares()<br>
2: *** Output *** <br>
3: 1<br>
4: 4<br>
5: 9<br>
6: 16<br>
7: 25<br>
8: 36<br>
9: 49<br>
10: 64<br>
11: 81<br>
12: 100<br>
15
+
## 4) Random Numbers
In the class **Numbers**, complete the method called **random4()** so that it returns a string of out four random integers between 1 and 10. The Unit Test is not provided for you, you must complete it.
16
+
17
+###Example<br>
18
+1: random4()<br>
2: *** Output *** <br>
3: 3<br>
4: 5<br>
5: 2<br>
6: 8<br>
19
+
## 5) Even Numbers < n

In the class **Numbers**, complete the method called **even()** so that it returns a string of the positive even numbers less than n. The Unit Test is not provided for you, you must complete it.

###Example<br>
20
+1: even(20)<br>
2: *** Output *** <br>
3: 2<br>
4: 4<br>
5: 6<br>
6: 8<br>
7: 10<br>
8: 12<br>
9: 14<br>
10: 16<br>
11: 18<br>
21
+
## 6) Powers of 2

In the class **Numbers**, complete the method called **powers()** so that it returns a string of out the powers of 2 from 2^1 up to to 2^n. The Unit Test is not provided for you, you must complete it.
22
+
23
+###Example<br>
24
+1: powers(8)<br>
2: *** Output *** <br>
3: 2<br>
4: 4<br>
5: 8<br>
6: 16<br>
7: 32<br>
8: 64<br>
9: 128<br>
10: 256<br>
25
+
## 7) Are we there yet?

In the class **CarRide**, complete the class so that it returns that outputs "Are we there yet?" and then waits for input. If the input is "Yes" the program ouputs "Good!" and exits, otherwite the program loops. The Unit Tests is not provided for you, you must complete it.
26
+
27
+###Example<br>
28
+1: "Are we there yet?"<br>
2: No<br>
3: "Are we there yet?"<br>
4: Spoons<br>
5: "Are we there yet?"<br>
6: Yes<br>
7: Good!<br>
29
+
## 8) Triangle

In the class **Shapes**, complete the method called **triangle()** so that it uses nested loops to produce the following pattern . The Unit Test is not provided for you, you must complete it.
30
+
31
+###Example<br>
1: triangle()<br>
2: *** Output *** <br>
3: * <br>
4: ** <br>
5: *** <br>
6: **** <br>
7: ***** <br>
32
+
## 9) Table Square

In the class **Shapes**, complete the method called **tableSquare()** so that it uses nested loops to produce a 4x4 table square. The Unit Test is not provided for you, you must complete it.
33
+
34
+###Example<br>
35
+tableSquare()<br>
*** Output *** <br>
A 4 x 4 table square<br>

36
+ ```
37
+ | 1 |  2 |  3 |  4 |
 | 2 |  4 |  6 |  8 |
38
+ | 3 |  6 |  9 | 12 |
39
+ | 4 |  8 | 12 | 16 |
40
+ 
41
+ ```
42
+
## 10) Table Squares

In the class **Shapes**, extend your answer to the last question produce a method that will return string of characters out og ***n x n*** table square. The Unit Test is not provided for you, you must complete it.
43
+
###Example<br>
44
+ tableSquares(6)<br>
 *** Output *** <br>
 A 6 x 6 table square<br>
45
+ 
46
+ ```
47
+ | 1 |  2 |  3 |  4 |  5 |  6 |
 | 2 |  4 |  6 |  8 | 10 | 12 |
48
+ | 3 |  6 |  9 | 12 | 15 | 18 |
49
+ | 4 |  8 | 12 | 16 | 20 | 24 |
50
+ | 5 | 10 | 15 | 20 | 25 | 30 |
51
+ | 6 | 12 | 18 | 24 | 30 | 36 |
52
+ ```
53
+ 

+ 20
- 0
pom.xml Parādīt failu

@@ -0,0 +1,20 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<project xmlns="http://maven.apache.org/POM/4.0.0"
3
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5
+    <modelVersion>4.0.0</modelVersion>
6
+
7
+    <groupId>io.zipcoder</groupId>
8
+    <artifactId>MicroLabs-Loops</artifactId>
9
+    <version>1.0-SNAPSHOT</version>
10
+
11
+    <dependencies>
12
+        <!-- https://mvnrepository.com/artifact/junit/junit -->
13
+        <dependency>
14
+            <groupId>junit</groupId>
15
+            <artifactId>junit</artifactId>
16
+            <version>4.12</version>
17
+        </dependency>
18
+
19
+    </dependencies>
20
+</project>

+ 9
- 0
src/main/java/io/zipcoder/microlabs/mastering_loops/CarRide.java Parādīt failu

@@ -0,0 +1,9 @@
1
+package io.zipcoder.microlabs.mastering_loops;
2
+
3
+public class CarRide {
4
+
5
+    public String areWeThereYetTest(){
6
+        return "";
7
+    }
8
+
9
+}

+ 30
- 0
src/main/java/io/zipcoder/microlabs/mastering_loops/Numbers.java Parādīt failu

@@ -0,0 +1,30 @@
1
+package io.zipcoder.microlabs.mastering_loops;
2
+
3
+
4
+public class Numbers {
5
+
6
+    public String oneToTen(){
7
+        return "";
8
+    }
9
+
10
+    public String oddNumbers(){
11
+        return "";
12
+    }
13
+
14
+    public String squares(){
15
+        return "";
16
+    }
17
+
18
+    public String random4(){
19
+        return "";
20
+    }
21
+
22
+    public String even(int n){
23
+        return "";
24
+    }
25
+
26
+    public String powers(int n){
27
+        return "";
28
+    }
29
+
30
+}

+ 17
- 0
src/main/java/io/zipcoder/microlabs/mastering_loops/Shapes.java Parādīt failu

@@ -0,0 +1,17 @@
1
+package io.zipcoder.microlabs.mastering_loops;
2
+
3
+
4
+public class Shapes {
5
+
6
+    public String triangle(){
7
+        return "";
8
+    }
9
+
10
+    public String tableSquare(){
11
+        return "";
12
+    }
13
+
14
+    public String tableSquares(int n){
15
+        return "";
16
+    }
17
+}

+ 9
- 0
src/test/java/io/zipcoder/microlabs/mastering_loops/CarRideTest.java Parādīt failu

@@ -0,0 +1,9 @@
1
+package io.zipcoder.microlabs.mastering_loops;
2
+
3
+
4
+import org.junit.Test;
5
+
6
+public class CarRideTest {
7
+
8
+
9
+}

+ 66
- 0
src/test/java/io/zipcoder/microlabs/mastering_loops/NumbersTest.java Parādīt failu

@@ -0,0 +1,66 @@
1
+package io.zipcoder.microlabs.mastering_loops;
2
+
3
+import org.junit.Assert;
4
+import org.junit.Test;
5
+
6
+public class NumbersTest {
7
+
8
+    @Test
9
+    public void oneToTenTest(){
10
+        //: Given
11
+        Numbers numbers = new Numbers();
12
+        String expected = "*** Output ***\noneToTen()\n1\n2\n3\n4\n5\n6\n7\n8\n9\n10";
13
+
14
+        //: When
15
+        String actual = numbers.oneToTen();
16
+
17
+        //: Then
18
+        Assert.assertEquals("The two strings are equal", expected, actual);
19
+    }
20
+
21
+    @Test
22
+    public void oddNumbersTest(){
23
+        //: Given
24
+
25
+        //: When
26
+
27
+        //: Then
28
+    }
29
+
30
+    @Test
31
+    public void squaresTest(){
32
+        //: Given
33
+
34
+        //: When
35
+
36
+        //: Then
37
+    }
38
+
39
+    @Test
40
+    public void random4Test(){
41
+        //: Given
42
+
43
+        //: When
44
+
45
+        //: Then
46
+    }
47
+
48
+    @Test
49
+    public void evenTest(){
50
+        //: Given
51
+
52
+        //: When
53
+
54
+        //: Then
55
+    }
56
+
57
+    @Test
58
+    public void powersTest(){
59
+        //: Given
60
+
61
+        //: When
62
+
63
+        //: Then
64
+    }
65
+
66
+}

+ 28
- 0
src/test/java/io/zipcoder/microlabs/mastering_loops/ShapesTest.java Parādīt failu

@@ -0,0 +1,28 @@
1
+package io.zipcoder.microlabs.mastering_loops;
2
+
3
+
4
+import org.junit.Test;
5
+import org.junit.Assert;
6
+
7
+public class ShapesTest {
8
+
9
+
10
+
11
+    @Test
12
+    public void triangleTest(){
13
+        //: Given
14
+
15
+        //: When
16
+
17
+        //: Then
18
+    }
19
+
20
+    @Test
21
+    public void tableSquareTest(){
22
+        //: Given
23
+
24
+        //: When
25
+
26
+        //: Then
27
+    }
28
+}