Browse Source

finished tests

Kr Younger 6 years ago
parent
commit
f9f5de533f
7 changed files with 529 additions and 85 deletions
  1. 9
    0
      .idea/FirstSaturday.iml
  2. 4
    0
      .idea/misc.xml
  3. 8
    0
      .idea/modules.xml
  4. 6
    0
      .idea/vcs.xml
  5. 274
    0
      .idea/workspace.xml
  6. 151
    83
      WriteLoops.java
  7. 77
    2
      WriteLoopsTest.java

+ 9
- 0
.idea/FirstSaturday.iml View File

1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<module type="JAVA_MODULE" version="4">
3
+  <component name="NewModuleRootManager" inherit-compiler-output="true">
4
+    <exclude-output />
5
+    <content url="file://$MODULE_DIR$" />
6
+    <orderEntry type="inheritedJdk" />
7
+    <orderEntry type="sourceFolder" forTests="false" />
8
+  </component>
9
+</module>

+ 4
- 0
.idea/misc.xml View File

1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<project version="4">
3
+  <component name="ProjectRootManager" version="2" project-jdk-name="1.8" project-jdk-type="JavaSDK" />
4
+</project>

+ 8
- 0
.idea/modules.xml View File

1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<project version="4">
3
+  <component name="ProjectModuleManager">
4
+    <modules>
5
+      <module fileurl="file://$PROJECT_DIR$/.idea/FirstSaturday.iml" filepath="$PROJECT_DIR$/.idea/FirstSaturday.iml" />
6
+    </modules>
7
+  </component>
8
+</project>

+ 6
- 0
.idea/vcs.xml View File

1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<project version="4">
3
+  <component name="VcsDirectoryMappings">
4
+    <mapping directory="" vcs="Git" />
5
+  </component>
6
+</project>

+ 274
- 0
.idea/workspace.xml View File

1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<project version="4">
3
+  <component name="ChangeListManager">
4
+    <list default="true" id="15642ba7-9000-4f98-9893-895a87389cf7" name="Default" comment="">
5
+      <change beforePath="$PROJECT_DIR$/WriteLoops.java" afterPath="$PROJECT_DIR$/WriteLoops.java" />
6
+    </list>
7
+    <option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
8
+    <option name="TRACKING_ENABLED" value="true" />
9
+    <option name="SHOW_DIALOG" value="false" />
10
+    <option name="HIGHLIGHT_CONFLICTS" value="true" />
11
+    <option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
12
+    <option name="LAST_RESOLUTION" value="IGNORE" />
13
+  </component>
14
+  <component name="FileEditorManager">
15
+    <leaf>
16
+      <file leaf-file-name="WriteLoops.java" pinned="false" current-in-tab="true">
17
+        <entry file="file://$PROJECT_DIR$/WriteLoops.java">
18
+          <provider selected="true" editor-type-id="text-editor">
19
+            <state relative-caret-position="300">
20
+              <caret line="402" column="42" lean-forward="true" selection-start-line="402" selection-start-column="42" selection-end-line="402" selection-end-column="42" />
21
+              <folding />
22
+            </state>
23
+          </provider>
24
+        </entry>
25
+      </file>
26
+    </leaf>
27
+  </component>
28
+  <component name="Git.Settings">
29
+    <option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
30
+  </component>
31
+  <component name="GradleLocalSettings">
32
+    <option name="externalProjectsViewState">
33
+      <projects_view />
34
+    </option>
35
+    <option name="projectSyncType">
36
+      <map>
37
+        <entry key="$USER_HOME$/GitHub/gs-gradle/initial" value="PREVIEW" />
38
+      </map>
39
+    </option>
40
+  </component>
41
+  <component name="JsBuildToolGruntFileManager" detection-done="true" sorting="DEFINITION_ORDER" />
42
+  <component name="JsBuildToolPackageJson" detection-done="true" sorting="DEFINITION_ORDER" />
43
+  <component name="JsGulpfileManager">
44
+    <detection-done>true</detection-done>
45
+    <sorting>DEFINITION_ORDER</sorting>
46
+  </component>
47
+  <component name="ProjectFrameBounds">
48
+    <option name="x" value="56" />
49
+    <option name="y" value="80" />
50
+    <option name="width" value="1440" />
51
+    <option name="height" value="828" />
52
+  </component>
53
+  <component name="ProjectView">
54
+    <navigator currentView="ProjectPane" proportions="" version="1">
55
+      <flattenPackages />
56
+      <showMembers />
57
+      <showModules />
58
+      <showLibraryContents />
59
+      <hideEmptyPackages />
60
+      <abbreviatePackageNames />
61
+      <autoscrollToSource />
62
+      <autoscrollFromSource />
63
+      <sortByType />
64
+      <manualOrder />
65
+      <foldersAlwaysOnTop value="true" />
66
+    </navigator>
67
+    <panes>
68
+      <pane id="Scope" />
69
+      <pane id="AndroidView" />
70
+      <pane id="ProjectPane">
71
+        <subPane>
72
+          <expand>
73
+            <path>
74
+              <item name="FirstSaturday" type="b2602c69:ProjectViewProjectNode" />
75
+              <item name="FirstSaturday" type="462c0819:PsiDirectoryNode" />
76
+            </path>
77
+          </expand>
78
+          <select />
79
+        </subPane>
80
+      </pane>
81
+      <pane id="PackagesPane" />
82
+      <pane id="Scratches" />
83
+    </panes>
84
+  </component>
85
+  <component name="PropertiesComponent">
86
+    <property name="nodejs_interpreter_path.stuck_in_default_project" value="undefined stuck path" />
87
+    <property name="settings.editor.selected.configurable" value="configurable.group.appearance" />
88
+    <property name="WebServerToolWindowFactoryState" value="false" />
89
+    <property name="aspect.path.notification.shown" value="true" />
90
+    <property name="last_opened_file_path" value="$PROJECT_DIR$" />
91
+  </component>
92
+  <component name="RunDashboard">
93
+    <option name="ruleStates">
94
+      <list>
95
+        <RuleState>
96
+          <option name="name" value="ConfigurationTypeDashboardGroupingRule" />
97
+        </RuleState>
98
+        <RuleState>
99
+          <option name="name" value="StatusDashboardGroupingRule" />
100
+        </RuleState>
101
+      </list>
102
+    </option>
103
+  </component>
104
+  <component name="RunManager">
105
+    <configuration default="true" type="Applet" factoryName="Applet">
106
+      <option name="WIDTH" value="400" />
107
+      <option name="HEIGHT" value="300" />
108
+      <option name="POLICY_FILE" value="$APPLICATION_HOME_DIR$/bin/appletviewer.policy" />
109
+      <module />
110
+    </configuration>
111
+    <configuration default="true" type="Application" factoryName="Application">
112
+      <extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea" />
113
+      <option name="MAIN_CLASS_NAME" />
114
+      <option name="VM_PARAMETERS" />
115
+      <option name="PROGRAM_PARAMETERS" />
116
+      <option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
117
+      <option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
118
+      <option name="ALTERNATIVE_JRE_PATH" />
119
+      <option name="ENABLE_SWING_INSPECTOR" value="false" />
120
+      <option name="ENV_VARIABLES" />
121
+      <option name="PASS_PARENT_ENVS" value="true" />
122
+      <module name="" />
123
+      <envs />
124
+    </configuration>
125
+    <configuration default="true" type="JUnit" factoryName="JUnit">
126
+      <extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea" />
127
+      <module name="" />
128
+      <option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
129
+      <option name="ALTERNATIVE_JRE_PATH" />
130
+      <option name="PACKAGE_NAME" />
131
+      <option name="MAIN_CLASS_NAME" />
132
+      <option name="METHOD_NAME" />
133
+      <option name="TEST_OBJECT" value="class" />
134
+      <option name="VM_PARAMETERS" value="-ea" />
135
+      <option name="PARAMETERS" />
136
+      <option name="WORKING_DIRECTORY" value="%MODULE_WORKING_DIR%" />
137
+      <option name="ENV_VARIABLES" />
138
+      <option name="PASS_PARENT_ENVS" value="true" />
139
+      <option name="TEST_SEARCH_SCOPE">
140
+        <value defaultName="singleModule" />
141
+      </option>
142
+      <envs />
143
+      <patterns />
144
+    </configuration>
145
+    <configuration default="true" type="Remote" factoryName="Remote">
146
+      <option name="USE_SOCKET_TRANSPORT" value="true" />
147
+      <option name="SERVER_MODE" value="false" />
148
+      <option name="SHMEM_ADDRESS" value="javadebug" />
149
+      <option name="HOST" value="localhost" />
150
+      <option name="PORT" value="5005" />
151
+    </configuration>
152
+    <configuration default="true" type="TestNG" factoryName="TestNG">
153
+      <extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea" />
154
+      <module name="" />
155
+      <option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
156
+      <option name="ALTERNATIVE_JRE_PATH" />
157
+      <option name="SUITE_NAME" />
158
+      <option name="PACKAGE_NAME" />
159
+      <option name="MAIN_CLASS_NAME" />
160
+      <option name="METHOD_NAME" />
161
+      <option name="GROUP_NAME" />
162
+      <option name="TEST_OBJECT" value="CLASS" />
163
+      <option name="VM_PARAMETERS" value="-ea" />
164
+      <option name="PARAMETERS" />
165
+      <option name="WORKING_DIRECTORY" value="%MODULE_WORKING_DIR%" />
166
+      <option name="OUTPUT_DIRECTORY" />
167
+      <option name="ANNOTATION_TYPE" />
168
+      <option name="ENV_VARIABLES" />
169
+      <option name="PASS_PARENT_ENVS" value="true" />
170
+      <option name="TEST_SEARCH_SCOPE">
171
+        <value defaultName="singleModule" />
172
+      </option>
173
+      <option name="USE_DEFAULT_REPORTERS" value="false" />
174
+      <option name="PROPERTIES_FILE" />
175
+      <envs />
176
+      <properties />
177
+      <listeners />
178
+    </configuration>
179
+    <configuration default="true" type="#org.jetbrains.idea.devkit.run.PluginConfigurationType" factoryName="Plugin">
180
+      <module name="" />
181
+      <option name="VM_PARAMETERS" value="-Xmx512m -Xms256m -XX:MaxPermSize=250m -ea" />
182
+      <option name="PROGRAM_PARAMETERS" />
183
+      <predefined_log_file id="idea.log" enabled="true" />
184
+    </configuration>
185
+  </component>
186
+  <component name="ShelveChangesManager" show_recycled="false">
187
+    <option name="remove_strategy" value="false" />
188
+  </component>
189
+  <component name="SvnConfiguration">
190
+    <configuration />
191
+  </component>
192
+  <component name="TaskManager">
193
+    <task active="true" id="Default" summary="Default task">
194
+      <changelist id="15642ba7-9000-4f98-9893-895a87389cf7" name="Default" comment="" />
195
+      <created>1538148602766</created>
196
+      <option name="number" value="Default" />
197
+      <option name="presentableId" value="Default" />
198
+      <updated>1538148602766</updated>
199
+      <workItem from="1538148604751" duration="59000" />
200
+    </task>
201
+    <servers />
202
+  </component>
203
+  <component name="TimeTrackingManager">
204
+    <option name="totallyTimeSpent" value="59000" />
205
+  </component>
206
+  <component name="ToolWindowManager">
207
+    <frame x="56" y="80" width="1440" height="828" extended-state="0" />
208
+    <editor active="true" />
209
+    <layout>
210
+      <window_info id="Palette" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="-1" side_tool="false" content_ui="tabs" />
211
+      <window_info id="TODO" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="6" side_tool="false" content_ui="tabs" />
212
+      <window_info id="Palette&#9;" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="-1" side_tool="false" content_ui="tabs" />
213
+      <window_info id="Image Layers" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="-1" side_tool="false" content_ui="tabs" />
214
+      <window_info id="Capture Analysis" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="-1" side_tool="false" content_ui="tabs" />
215
+      <window_info id="Event Log" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="-1" side_tool="true" content_ui="tabs" />
216
+      <window_info id="Maven Projects" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="-1" side_tool="false" content_ui="tabs" />
217
+      <window_info id="Run" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" />
218
+      <window_info id="Version Control" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="-1" side_tool="false" content_ui="tabs" />
219
+      <window_info id="Terminal" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="-1" side_tool="false" content_ui="tabs" />
220
+      <window_info id="Capture Tool" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="-1" side_tool="false" content_ui="tabs" />
221
+      <window_info id="Designer" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="-1" side_tool="false" content_ui="tabs" />
222
+      <window_info id="Project" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="0" side_tool="false" content_ui="combo" />
223
+      <window_info id="Database" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="-1" side_tool="false" content_ui="tabs" />
224
+      <window_info id="Structure" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
225
+      <window_info id="Ant Build" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
226
+      <window_info id="UI Designer" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="-1" side_tool="false" content_ui="tabs" />
227
+      <window_info id="Theme Preview" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="-1" side_tool="false" content_ui="tabs" />
228
+      <window_info id="Debug" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.4" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
229
+      <window_info id="Favorites" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="-1" side_tool="true" content_ui="tabs" />
230
+      <window_info id="Cvs" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="4" side_tool="false" content_ui="tabs" />
231
+      <window_info id="Hierarchy" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="2" side_tool="false" content_ui="combo" />
232
+      <window_info id="Message" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
233
+      <window_info id="Commander" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.4" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
234
+      <window_info id="Find" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
235
+      <window_info id="Inspection" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.4" sideWeight="0.5" order="5" side_tool="false" content_ui="tabs" />
236
+    </layout>
237
+  </component>
238
+  <component name="TypeScriptGeneratedFilesManager">
239
+    <option name="version" value="1" />
240
+  </component>
241
+  <component name="VcsContentAnnotationSettings">
242
+    <option name="myLimit" value="2678400000" />
243
+  </component>
244
+  <component name="XDebuggerManager">
245
+    <breakpoint-manager />
246
+    <watches-manager />
247
+  </component>
248
+  <component name="editorHistoryManager">
249
+    <entry file="file://$PROJECT_DIR$/WriteLoops.java">
250
+      <provider selected="true" editor-type-id="text-editor">
251
+        <state relative-caret-position="300">
252
+          <caret line="402" column="42" lean-forward="true" selection-start-line="402" selection-start-column="42" selection-end-line="402" selection-end-column="42" />
253
+          <folding />
254
+        </state>
255
+      </provider>
256
+    </entry>
257
+  </component>
258
+  <component name="masterDetails">
259
+    <states>
260
+      <state key="ProjectJDKs.UI">
261
+        <settings>
262
+          <last-edited>1.8</last-edited>
263
+          <splitter-proportions>
264
+            <option name="proportions">
265
+              <list>
266
+                <option value="0.2" />
267
+              </list>
268
+            </option>
269
+          </splitter-proportions>
270
+        </settings>
271
+      </state>
272
+    </states>
273
+  </component>
274
+</project>

+ 151
- 83
WriteLoops.java View File

1
 import com.sun.org.apache.xpath.internal.SourceTree;
1
 import com.sun.org.apache.xpath.internal.SourceTree;
2
 
2
 
3
+import java.awt.SystemTray;
4
+import java.util.concurrent.ThreadLocalRandom;
5
+import java.util.function.Supplier;
6
+
3
 /**
7
 /**
4
  * Writeloops get you thinking about how to do different things with loops.
8
  * Writeloops get you thinking about how to do different things with loops.
5
  *
9
  *
28
         int w = 0;
32
         int w = 0;
29
 
33
 
30
         // Write a FOR loop that counts from 1 to 10.
34
         // Write a FOR loop that counts from 1 to 10.
31
-
35
+        for (int i = 1; i <= 10; i++) {
32
         // calling
36
         // calling
33
         w = w + 1;
37
         w = w + 1;
34
         // each time through the loop
38
         // each time through the loop
35
-
39
+        }
36
         return w;
40
         return w;
37
     }
41
     }
38
 
42
 
40
         int w = 0;
44
         int w = 0;
41
 
45
 
42
         // Write a FOR loop that makes 10 iterations, start at 21.
46
         // Write a FOR loop that makes 10 iterations, start at 21.
43
-
47
+        for (int i = 21; i <= (21 + 10); i++) {
44
         // calling
48
         // calling
45
         w = w + 1;
49
         w = w + 1;
46
         // each time through the loop
50
         // each time through the loop
47
-
51
+        }
48
         return w;
52
         return w;
49
     }
53
     }
50
 
54
 
52
         int w = 0;
56
         int w = 0;
53
 
57
 
54
         // Write a FOR loop that counts down from 100 to 0.
58
         // Write a FOR loop that counts down from 100 to 0.
55
-
59
+        for (int i = 100; i > 0; i--) {
56
         // calling
60
         // calling
57
         w = w + 1;
61
         w = w + 1;
58
         // each time through the loop
62
         // each time through the loop
59
-
63
+        }
60
         return w;
64
         return w;
61
     }
65
     }
62
 
66
 
64
         int w = 0;
68
         int w = 0;
65
 
69
 
66
         // Write a FOR loop from 0 to 32 by 2s.
70
         // Write a FOR loop from 0 to 32 by 2s.
67
-
71
+        for (int i = 0; i == 32; i += 2) {
68
         // calling
72
         // calling
69
         w = w + 1;
73
         w = w + 1;
70
         // each time through the loop
74
         // each time through the loop
71
-
75
+        }
72
         return w;
76
         return w;
73
     }
77
     }
74
 
78
 
76
         int w = 0;
80
         int w = 0;
77
 
81
 
78
         // Write a FOR loop from 1 to less than 5001 by 11s.
82
         // Write a FOR loop from 1 to less than 5001 by 11s.
79
-
83
+        for (int i = 1; i < 5001; i = i + 11) {
80
         // calling
84
         // calling
81
         w = w + 1;
85
         w = w + 1;
82
         // each time through the loop
86
         // each time through the loop
83
-
87
+        }
84
         return w;
88
         return w;
85
     }
89
     }
86
 
90
 
89
 
93
 
90
         // Write a nested FOR loop(s), where one counts from
94
         // Write a nested FOR loop(s), where one counts from
91
         // 0 to less than 20 and the inner one counts from 0 to 4
95
         // 0 to less than 20 and the inner one counts from 0 to 4
92
-
93
-        // calling
94
-        w = w + 1;
95
-        // each time through the inner loop
96
-
96
+        for (int i = 0; i < 20; i++) {
97
+            for (int j = 0; j <= 4; j++) {
98
+                // calling
99
+                w = w + 1;
100
+                // each time through the inner loop
101
+            }
102
+        }
97
         return w;
103
         return w;
98
     }
104
     }
99
 
105
 
104
         // statement inside the loop that checks the
110
         // statement inside the loop that checks the
105
         // loop index counter and if it’s greater than 51,
111
         // loop index counter and if it’s greater than 51,
106
         // prints “Hello Zipcode” instead of the statement w = w + 1;
112
         // prints “Hello Zipcode” instead of the statement w = w + 1;
107
-
108
-        // calling
109
-        w = w + 1;
110
-        // each time through the inner loop
111
-
113
+        for (int index = 5; index < 105; index++) {
114
+            if (index > 51) {
115
+                System.out.print("Hello Zipcode ");
116
+            } else
117
+                // calling
118
+                w = w + 1;
119
+            // each time through the inner loop
120
+        }
112
         return w;
121
         return w;
113
     }
122
     }
114
 
123
 
137
         int w = 0;
146
         int w = 0;
138
 
147
 
139
         // you need to use a .equals for two Strings.
148
         // you need to use a .equals for two Strings.
140
-
141
-        // calling
142
-        w = w + 1;
143
-        // each time through the inner loop
144
-
149
+        while (gpsCurrentLocation().equalsIgnoreCase("Home") == false) {
150
+            driveSomeMore();
151
+            // calling
152
+            w = w + 1;
153
+            // each time through the inner loop
154
+        }
145
         System.out.println("Honey, I’m Home!");
155
         System.out.println("Honey, I’m Home!");
146
         return w;
156
         return w;
147
     }
157
     }
148
 
158
 
149
     // Getting harder...
159
     // Getting harder...
150
     // First declare and set “highestScore” to 236. Then set “currentScore” to
160
     // First declare and set “highestScore” to 236. Then set “currentScore” to
151
-    // “gameNextScore()”. Then write a WHILE loop that checks “currentScore”
161
+    // “gameNextScore()”. Then write a WHILE loop that checks "runningScore"
152
     // is less than “highestScore” and if it is, adds “currentScore” to
162
     // is less than “highestScore” and if it is, adds “currentScore” to
153
     // "runningScore"
163
     // "runningScore"
154
     // and then sets “currentScore” to “gameNextScore()”
164
     // and then sets “currentScore” to “gameNextScore()”
155
-    public boolean checkGameScore() {
165
+    public int checkGameScore() {
156
         int w = 0;
166
         int w = 0;
157
         int highestScore = 236;
167
         int highestScore = 236;
158
         int currentScore = gameNextScore();
168
         int currentScore = gameNextScore();
159
         int runningScore = 0;
169
         int runningScore = 0;
160
 
170
 
161
         // do your while loop here
171
         // do your while loop here
162
-
163
-        // do your ifs here
164
-
165
-        // calling
166
-        w = w + 1;
167
-        // each time through the inner loop
168
-
169
-        return w > 3;
172
+        while (runningScore < highestScore) {
173
+            // do your ifs here
174
+            runningScore += currentScore;
175
+            currentScore = gameNextScore();
176
+            // calling
177
+            w = w + 1;
178
+            // each time through the inner loop
179
+        }
180
+        System.out.println(w);
181
+        return w; // >= 3;
170
     }
182
     }
171
 
183
 
172
     // Rewrite the previous WHILE loop as a DO..WHILE loop.
184
     // Rewrite the previous WHILE loop as a DO..WHILE loop.
178
         int runningScore = 0;
190
         int runningScore = 0;
179
 
191
 
180
         // do your while loop here
192
         // do your while loop here
193
+        do {
194
+            runningScore += currentScore;
195
+            currentScore = gameNextScore();
196
+            // calling
197
+            w = w + 1;
198
+            // each time through the inner loop
199
+        } while (currentScore < highestScore);
181
 
200
 
182
-        // do your ifs here
183
-
184
-        // calling
185
-        w = w + 1;
186
-        // each time through the inner loop
187
-
188
-        return w > 3;
201
+        return w >= 3;
189
     }
202
     }
190
 
203
 
191
     // Write a WHILE loop that checks “serverIsRunning()” and if true
204
     // Write a WHILE loop that checks “serverIsRunning()” and if true
194
     // and also calls “tryServerRestart()”
207
     // and also calls “tryServerRestart()”
195
     public int checkServerStatus() {
208
     public int checkServerStatus() {
196
         int w = 0;
209
         int w = 0;
197
-        String adminPhoneNumber = "+1 202 456 1111"
210
+        String adminPhoneNumber = "+1 202 456 1111";
211
+        
212
+        while (serverIsRunning()) {
213
+            waitFor(5);
198
         // calling
214
         // calling
199
         w = w + 1;
215
         w = w + 1;
200
         // each time through the inner loop
216
         // each time through the inner loop
201
-
217
+        }
218
+        if (serverIsRunning() == false) {
219
+            sendEmergencyText("Help!", adminPhoneNumber);
220
+        }
221
+        
202
         return w;
222
         return w;
203
     }
223
     }
204
 
224
 
208
     public int loop50by7() {
228
     public int loop50by7() {
209
         int w = 0;
229
         int w = 0;
210
 
230
 
211
-        // calling
212
-        w = w + 1;
213
-        // each time through the inner loop
231
+        int i = 7;
214
 
232
 
233
+        while (i < 50) {
234
+            i = i + 7;
235
+            // calling
236
+            w = w + 1;
237
+            // each time through the inner loop
238
+        }
215
         return w;
239
         return w;
216
     }
240
     }
217
 
241
 
242
+    int[] threes_array = { 3, 6, 9, 12, 15, 18, 21 };
243
+
218
     // Foo is method that add the first 7 factors of three together and prints
244
     // Foo is method that add the first 7 factors of three together and prints
219
     // out the sum of them all.
245
     // out the sum of them all.
220
     public int foo() {
246
     public int foo() {
221
         int w = 0;
247
         int w = 0;
222
         // this is an array of ints. it is of length 7 (from 0 -> 6)
248
         // this is an array of ints. it is of length 7 (from 0 -> 6)
223
-        int[] threes_array = { 3, 6, 9, 12, 15, 18, 21 };
224
         int sumOfThrees = 0;
249
         int sumOfThrees = 0;
225
 
250
 
226
         // this is a so called Enhanced for loop
251
         // this is a so called Enhanced for loop
243
         int w = 0;
268
         int w = 0;
244
         int sumOfThrees = 0;
269
         int sumOfThrees = 0;
245
 
270
 
246
-        // calling
247
-        w = w + 1;
248
-        // each time through the inner loop
271
+        for (int index = 0; index < threes_array.length; index++) {
272
+            sumOfThrees = sumOfThrees + threes_array[index];
249
 
273
 
274
+            // calling
275
+            w = w + 1;
276
+            // each time through the inner loop
277
+        }
250
         System.out.print("The Sum is ");
278
         System.out.print("The Sum is ");
251
         System.out.println(sumOfThrees);
279
         System.out.println(sumOfThrees);
252
 
280
 
259
         int w = 0;
287
         int w = 0;
260
         int sumOfThrees = 0;
288
         int sumOfThrees = 0;
261
 
289
 
262
-        // calling
263
-        w = w + 1;
264
-        // each time through the inner loop
265
-
290
+        int index = 0;
291
+        while (index < threes_array.length) {
292
+            sumOfThrees = sumOfThrees + threes_array[index];
293
+            index++;
294
+            // calling
295
+            w = w + 1;
296
+            // each time through the inner loop
297
+        }
266
         System.out.print("The Sum is ");
298
         System.out.print("The Sum is ");
267
         System.out.println(sumOfThrees);
299
         System.out.println(sumOfThrees);
268
 
300
 
274
     // inside the loop, write an IF that checks “yardNeedsMowed” and if true calls
306
     // inside the loop, write an IF that checks “yardNeedsMowed” and if true calls
275
     // “yellAtJuniorToMowLawn()”
307
     // “yellAtJuniorToMowLawn()”
276
     // After loop, call
308
     // After loop, call
277
-    // “sendJuniorBackToSchool(onTime)”
309
+    // “sendJuniorBackToSchool()” with an argument that decribes the day junior goes
310
+    // back.
278
     public int manageYardAndJunior() {
311
     public int manageYardAndJunior() {
279
         int w = 0;
312
         int w = 0;
280
         boolean onTime = true;
313
         boolean onTime = true;
281
 
314
 
282
         // ADD YOUR CODE here.
315
         // ADD YOUR CODE here.
283
-
284
-        // be sure to call
285
-        w = w + 1;
286
-        // each time inside the loop
287
-
316
+        boolean yardNeedsMowed = true;
317
+        while (isSummer()) {
318
+            if (yardNeedsMowed) {
319
+                yellAtJuniorToMowLawn();
320
+            }
321
+            // be sure to call
322
+            w = w + 1;
323
+            // each time inside the loop
324
+        }
325
+        sendJuniorBackToSchool("first Day Of school");
288
         return w;
326
         return w;
289
     }
327
     }
290
 
328
 
291
-    String voteTallies[] = { "Lincoln", "Washington", "Adams",
292
-    "Lincoln", "Washington", "Adams", "Lincoln", "Washington", "Adams",
293
-    "Lincoln", "Washington", "Adams", "Roosevelt"
294
-    };
329
+    String voteTallies[] = { "Lincoln", "Washington", "Adams", "Lincoln", "Washington", "Adams", "Lincoln",
330
+            "Washington", "Adams", "Lincoln", "Washington", "Adams", "Roosevelt" };
331
+
295
     // Given an array voteTallies[], write a FOR loop that prints out each value in
332
     // Given an array voteTallies[], write a FOR loop that prints out each value in
296
     // the array.
333
     // the array.
297
     public int tallyVote1() {
334
     public int tallyVote1() {
298
         int w = 0;
335
         int w = 0;
299
         int numberOfVotes = voteTallies.length;
336
         int numberOfVotes = voteTallies.length;
300
 
337
 
301
-        // calling
302
-        w = w + 1;
303
-        // each time through the inner loop
304
-
338
+        for (int index = 0; index < numberOfVotes; index++) {
339
+            System.out.println(voteTallies[index]);
340
+            // calling
341
+            w = w + 1;
342
+            // each time through the inner loop
343
+        }
305
         return w;
344
         return w;
306
     }
345
     }
307
 
346
 
312
         int w = 0;
351
         int w = 0;
313
         int numberOfVotes = voteTallies.length;
352
         int numberOfVotes = voteTallies.length;
314
 
353
 
315
-        // calling
316
-        w = w + 1;
317
-        // each time through the inner loop
354
+        int index = 0;
318
 
355
 
356
+        while (index < numberOfVotes) {
357
+            System.out.println(voteTallies[index]);
358
+            // calling
359
+            w = w + 1;
360
+            // each time through the inner loop
361
+        }
319
         return w;
362
         return w;
320
     }
363
     }
321
 
364
 
362
         return this.scr = this.scr + ThreadLocalRandom.current().nextInt(20, 99 + 1);
405
         return this.scr = this.scr + ThreadLocalRandom.current().nextInt(20, 99 + 1);
363
     }
406
     }
364
 
407
 
365
-    private boolean isSummer = () -> {
366
-        int i = 0;
367
-        return () -> {
368
-            i = i + 1;
369
-            return (i >= _3);
370
-        };
371
-    };
408
+    private void yellAtJuniorToMowLawn() {
409
+        /* dammit, mow the yard */}
410
+
411
+    private void sendJuniorBackToSchool(String timeForSchool) {
412
+        if (!timeForSchool.equalsIgnoreCase("First Day of School")) {
413
+            throw new IllegalArgumentException();
414
+        }
415
+        /* dammit, mow the yard */}
416
+
417
+    // private Supplier<Boolean> isSummer = () -> {
418
+    //     int i = 0;
419
+    //     return Supplier<Boolean> () -> {
420
+    //         i = i + 1;
421
+    //         return (i >= 3);
422
+    //     };
423
+    // };
424
+        private int summer = 0;
425
+        private boolean isSummer() {
426
+            if (summer == 3) {
427
+                return true;
428
+            }
429
+            summer++;
430
+            return false;
431
+        }
432
+    private void sendEmergencyText(String mesg, String phone) {
433
+    }
434
+
435
+    private void tryServerRestart(String mesg, String phone) {
436
+    }
372
 
437
 
373
-    private void sendEmergencyText(String mesg, String phone) {}
374
-    private void tryServerRestart(String mesg, String phone) {}
375
     int serverStatus = 5;
438
     int serverStatus = 5;
376
-    private boolean serverIsRunning() {return (serverStatus > 20);}
377
-    private void waitFor(int interval) {serverStatus += interval;}
378
 
439
 
440
+    private boolean serverIsRunning() {
441
+        return (serverStatus < 20);
442
+    }
443
+
444
+    private void waitFor(int interval) {
445
+        serverStatus += interval;
446
+    }
379
 
447
 
380
 }
448
 }

+ 77
- 2
WriteLoopsTest.java View File

51
     public void TestOneToTen()
51
     public void TestOneToTen()
52
     {
52
     {
53
         WriteLoops writeLoo1 = new WriteLoops();
53
         WriteLoops writeLoo1 = new WriteLoops();
54
-        assertEquals(5, writeLoo1.oneToTen());
54
+        assertEquals(10, writeLoo1.oneToTen());
55
     }
55
     }
56
     @Test
56
     @Test
57
     public void TestStartAtTwentyOne()
57
     public void TestStartAtTwentyOne()
58
     {
58
     {
59
         WriteLoops writeLoo1 = new WriteLoops();
59
         WriteLoops writeLoo1 = new WriteLoops();
60
-        assertEquals(5, writeLoo1.startAtTwentyOne());
60
+        assertEquals(11, writeLoo1.startAtTwentyOne());
61
+    }
62
+
63
+    @Test
64
+    public void TestCountDown()
65
+    {
66
+        WriteLoops writeLoo1 = new WriteLoops();
67
+        assertEquals(100, writeLoo1.countDown());
68
+    }
69
+
70
+    @Test
71
+    public void Test2to32()
72
+    {
73
+        WriteLoops writeLoo1 = new WriteLoops();
74
+        assertEquals(0, writeLoo1.byTwoTo32());
75
+    }
76
+
77
+    @Test
78
+    public void TestCountDownFrom5000()
79
+    {
80
+        WriteLoops writeLoo1 = new WriteLoops();
81
+        assertEquals(455, writeLoo1.countDownFrom5000());
82
+    }
83
+
84
+    @Test
85
+    public void TestNestedFors()
86
+    {
87
+        WriteLoops writeLoo1 = new WriteLoops();
88
+        assertEquals(100, writeLoo1.nestedFors());
89
+    }
90
+
91
+    @Test
92
+    public void TestHelloZipCode()
93
+    {
94
+        WriteLoops writeLoo1 = new WriteLoops();
95
+        assertEquals(47, writeLoo1.helloZipCode());
96
+    }
97
+
98
+    @Test
99
+    public void TestDriveHome()
100
+    {
101
+        WriteLoops writeLoo1 = new WriteLoops();
102
+        assertEquals(6, writeLoo1.driveHome());
103
+    }
104
+
105
+
106
+
107
+    @Test
108
+    public void TestCheckGameScore()
109
+    {
110
+        WriteLoops writeLoo1 = new WriteLoops();
111
+        assertEquals(3, writeLoo1.checkGameScore());
112
+    }
113
+
114
+    @Test
115
+    public void TestCheckGameScoreDoWhile()
116
+    {
117
+        WriteLoops writeLoo1 = new WriteLoops();
118
+        assertEquals(true, writeLoo1.checkGameScoreDoWhile());
119
+    }
120
+
121
+    @Test
122
+    public void TestCheckServer()
123
+    {
124
+        WriteLoops writeLoo1 = new WriteLoops();
125
+        assertEquals(3, writeLoo1.checkServerStatus());
61
     }
126
     }
62
 }
127
 }
63
 
128
 
129
+
130
+
131
+
132
+
133
+
134
+
135
+
136
+
137
+
138
+