Jared Norris 8 gadus atpakaļ
vecāks
revīzija
1ca583768f

+ 9
- 0
.idea/ZCW-Money-Converter-BlueJ.iml Parādīt failu

@@ -0,0 +1,9 @@
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>

+ 7
- 0
.idea/misc.xml Parādīt failu

@@ -0,0 +1,7 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<project version="4">
3
+  <component name="JavaScriptSettings">
4
+    <option name="languageLevel" value="ES6" />
5
+  </component>
6
+  <component name="ProjectRootManager" version="2" project-jdk-name="1.8" project-jdk-type="JavaSDK" />
7
+</project>

+ 8
- 0
.idea/modules.xml Parādīt failu

@@ -0,0 +1,8 @@
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/ZCW-Money-Converter-BlueJ.iml" filepath="$PROJECT_DIR$/.idea/ZCW-Money-Converter-BlueJ.iml" />
6
+    </modules>
7
+  </component>
8
+</project>

+ 6
- 0
.idea/vcs.xml Parādīt failu

@@ -0,0 +1,6 @@
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>

+ 297
- 0
.idea/workspace.xml Parādīt failu

@@ -0,0 +1,297 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<project version="4">
3
+  <component name="ChangeListManager">
4
+    <list default="true" id="dd3d9770-4a79-48c4-a374-b1a5958018a5" name="Default" comment="">
5
+      <change afterPath="$PROJECT_DIR$/.idea/vcs.xml" afterDir="false" />
6
+      <change beforePath="$PROJECT_DIR$/CurrencyConverter.java" beforeDir="false" afterPath="$PROJECT_DIR$/CurrencyConverter.java" afterDir="false" />
7
+      <change beforePath="$PROJECT_DIR$/CurrencyConverterTest.java" beforeDir="false" afterPath="$PROJECT_DIR$/CurrencyConverterTest.java" afterDir="false" />
8
+      <change beforePath="$PROJECT_DIR$/package.bluej" beforeDir="false" afterPath="$PROJECT_DIR$/package.bluej" afterDir="false" />
9
+    </list>
10
+    <option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
11
+    <option name="TRACKING_ENABLED" value="true" />
12
+    <option name="SHOW_DIALOG" value="false" />
13
+    <option name="HIGHLIGHT_CONFLICTS" value="true" />
14
+    <option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
15
+    <option name="LAST_RESOLUTION" value="IGNORE" />
16
+  </component>
17
+  <component name="FileEditorManager">
18
+    <leaf>
19
+      <file leaf-file-name="CurrencyConverter.class" pinned="false" current-in-tab="true">
20
+        <entry file="file://$PROJECT_DIR$/CurrencyConverter.class">
21
+          <provider selected="true" editor-type-id="text-editor">
22
+            <state relative-caret-position="735">
23
+              <caret line="73" column="50" lean-forward="true" selection-start-line="6" selection-start-column="4" selection-end-line="73" selection-end-column="50" />
24
+              <folding>
25
+                <element signature="e#0#1688#0" expanded="true" />
26
+              </folding>
27
+            </state>
28
+          </provider>
29
+        </entry>
30
+      </file>
31
+      <file leaf-file-name="CurrencyConverter.java" pinned="false" current-in-tab="false">
32
+        <entry file="file://$PROJECT_DIR$/CurrencyConverter.java">
33
+          <provider selected="true" editor-type-id="text-editor">
34
+            <state relative-caret-position="210">
35
+              <caret line="16" column="5" lean-forward="true" selection-start-line="1" selection-start-column="3" selection-end-line="16" selection-end-column="5" />
36
+            </state>
37
+          </provider>
38
+        </entry>
39
+      </file>
40
+      <file leaf-file-name="CurrencyConverterTest.class" pinned="false" current-in-tab="false">
41
+        <entry file="file://$PROJECT_DIR$/CurrencyConverterTest.class">
42
+          <provider selected="true" editor-type-id="text-editor">
43
+            <state>
44
+              <folding>
45
+                <element signature="e#0#1307#0" expanded="true" />
46
+              </folding>
47
+            </state>
48
+          </provider>
49
+        </entry>
50
+      </file>
51
+    </leaf>
52
+  </component>
53
+  <component name="Git.Settings">
54
+    <option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
55
+  </component>
56
+  <component name="GradleLocalSettings">
57
+    <option name="projectSyncType">
58
+      <map>
59
+        <entry key="$USER_HOME$/LearnSpring/giflib-hibernate" value="PREVIEW" />
60
+      </map>
61
+    </option>
62
+  </component>
63
+  <component name="IdeDocumentHistory">
64
+    <option name="CHANGED_PATHS">
65
+      <list>
66
+        <option value="$PROJECT_DIR$/CurrencyConverter.java" />
67
+      </list>
68
+    </option>
69
+  </component>
70
+  <component name="JsBuildToolGruntFileManager" detection-done="true" sorting="DEFINITION_ORDER" />
71
+  <component name="JsBuildToolPackageJson" detection-done="true" sorting="DEFINITION_ORDER" />
72
+  <component name="JsGulpfileManager">
73
+    <detection-done>true</detection-done>
74
+    <sorting>DEFINITION_ORDER</sorting>
75
+  </component>
76
+  <component name="NodePackageJsonFileManager">
77
+    <packageJsonPaths />
78
+  </component>
79
+  <component name="ProjectFrameBounds">
80
+    <option name="x" value="-358" />
81
+    <option name="y" value="-1046" />
82
+    <option name="width" value="1920" />
83
+    <option name="height" value="1057" />
84
+  </component>
85
+  <component name="ProjectView">
86
+    <navigator proportions="" version="1">
87
+      <foldersAlwaysOnTop value="true" />
88
+    </navigator>
89
+    <panes>
90
+      <pane id="Scope" />
91
+      <pane id="ProjectPane">
92
+        <subPane>
93
+          <expand>
94
+            <path>
95
+              <item name="ZCW-Money-Converter-BlueJ" type="b2602c69:ProjectViewProjectNode" />
96
+              <item name="ZCW-Money-Converter-BlueJ" type="462c0819:PsiDirectoryNode" />
97
+            </path>
98
+          </expand>
99
+          <select />
100
+        </subPane>
101
+      </pane>
102
+      <pane id="PackagesPane" />
103
+      <pane id="AndroidView" />
104
+    </panes>
105
+  </component>
106
+  <component name="PropertiesComponent">
107
+    <property name="WebServerToolWindowFactoryState" value="false" />
108
+    <property name="aspect.path.notification.shown" value="true" />
109
+    <property name="last_opened_file_path" value="$PROJECT_DIR$" />
110
+    <property name="nodejs_interpreter_path.stuck_in_default_project" value="undefined stuck path" />
111
+    <property name="nodejs_npm_path_reset_for_default_project" value="true" />
112
+    <property name="settings.editor.selected.configurable" value="project.propGUI" />
113
+  </component>
114
+  <component name="RunDashboard">
115
+    <option name="ruleStates">
116
+      <list>
117
+        <RuleState>
118
+          <option name="name" value="ConfigurationTypeDashboardGroupingRule" />
119
+        </RuleState>
120
+        <RuleState>
121
+          <option name="name" value="StatusDashboardGroupingRule" />
122
+        </RuleState>
123
+      </list>
124
+    </option>
125
+  </component>
126
+  <component name="RunManager">
127
+    <configuration default="true" type="Application" factoryName="Application">
128
+      <option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
129
+    </configuration>
130
+    <configuration name="CurrencyConverterTest" type="JUnit" factoryName="JUnit" temporary="true" nameIsGenerated="true">
131
+      <module name="ZCW-Money-Converter-BlueJ" />
132
+      <option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
133
+      <option name="ALTERNATIVE_JRE_PATH" />
134
+      <option name="PACKAGE_NAME" value="" />
135
+      <option name="MAIN_CLASS_NAME" value="CurrencyConverterTest" />
136
+      <option name="METHOD_NAME" />
137
+      <option name="TEST_OBJECT" value="class" />
138
+      <option name="VM_PARAMETERS" value="-ea" />
139
+      <option name="PARAMETERS" />
140
+      <option name="WORKING_DIRECTORY" value="%MODULE_WORKING_DIR%" />
141
+      <option name="PASS_PARENT_ENVS" value="true" />
142
+      <option name="TEST_SEARCH_SCOPE">
143
+        <value defaultName="singleModule" />
144
+      </option>
145
+      <patterns />
146
+    </configuration>
147
+    <configuration default="true" type="JUnit" factoryName="JUnit">
148
+      <option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
149
+      <option name="ALTERNATIVE_JRE_PATH" />
150
+      <option name="PACKAGE_NAME" />
151
+      <option name="MAIN_CLASS_NAME" />
152
+      <option name="METHOD_NAME" />
153
+      <option name="TEST_OBJECT" value="class" />
154
+      <option name="VM_PARAMETERS" value="-ea" />
155
+      <option name="PARAMETERS" />
156
+      <option name="WORKING_DIRECTORY" value="%MODULE_WORKING_DIR%" />
157
+      <option name="PASS_PARENT_ENVS" value="true" />
158
+      <option name="TEST_SEARCH_SCOPE">
159
+        <value defaultName="singleModule" />
160
+      </option>
161
+      <patterns />
162
+    </configuration>
163
+    <configuration default="true" type="TestNG" factoryName="TestNG">
164
+      <option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
165
+      <option name="ALTERNATIVE_JRE_PATH" />
166
+      <option name="SUITE_NAME" />
167
+      <option name="PACKAGE_NAME" />
168
+      <option name="MAIN_CLASS_NAME" />
169
+      <option name="METHOD_NAME" />
170
+      <option name="GROUP_NAME" />
171
+      <option name="TEST_OBJECT" value="CLASS" />
172
+      <option name="VM_PARAMETERS" value="-ea" />
173
+      <option name="PARAMETERS" />
174
+      <option name="WORKING_DIRECTORY" value="%MODULE_WORKING_DIR%" />
175
+      <option name="OUTPUT_DIRECTORY" />
176
+      <option name="PASS_PARENT_ENVS" value="true" />
177
+      <option name="TEST_SEARCH_SCOPE">
178
+        <value defaultName="singleModule" />
179
+      </option>
180
+      <option name="USE_DEFAULT_REPORTERS" value="false" />
181
+      <option name="PROPERTIES_FILE" />
182
+      <properties />
183
+      <listeners />
184
+    </configuration>
185
+    <recent_temporary>
186
+      <list>
187
+        <item itemvalue="JUnit.CurrencyConverterTest" />
188
+      </list>
189
+    </recent_temporary>
190
+  </component>
191
+  <component name="SvnConfiguration">
192
+    <configuration />
193
+  </component>
194
+  <component name="TaskManager">
195
+    <task active="true" id="Default" summary="Default task">
196
+      <changelist id="dd3d9770-4a79-48c4-a374-b1a5958018a5" name="Default" comment="" />
197
+      <created>1530109089014</created>
198
+      <option name="number" value="Default" />
199
+      <option name="presentableId" value="Default" />
200
+      <updated>1530109089014</updated>
201
+      <workItem from="1530109090621" duration="798000" />
202
+    </task>
203
+    <servers />
204
+  </component>
205
+  <component name="TestHistory">
206
+    <history-entry file="CurrencyConverterTest - 2018.06.27 at 10h 20m 06s.xml">
207
+      <configuration name="CurrencyConverterTest" configurationId="JUnit" />
208
+    </history-entry>
209
+  </component>
210
+  <component name="TimeTrackingManager">
211
+    <option name="totallyTimeSpent" value="798000" />
212
+  </component>
213
+  <component name="ToolWindowManager">
214
+    <frame x="-358" y="-1046" width="1920" height="1057" extended-state="0" />
215
+    <layout>
216
+      <window_info anchor="right" id="Palette" />
217
+      <window_info anchor="bottom" id="TODO" order="6" />
218
+      <window_info anchor="bottom" id="Messages" />
219
+      <window_info anchor="right" id="Palette&#9;" />
220
+      <window_info id="Image Layers" />
221
+      <window_info anchor="right" id="Capture Analysis" />
222
+      <window_info anchor="bottom" id="Event Log" side_tool="true" />
223
+      <window_info anchor="right" id="Maven Projects" />
224
+      <window_info anchor="bottom" id="Database Changes" show_stripe_button="false" />
225
+      <window_info anchor="bottom" id="Run" order="2" weight="0.32916668" />
226
+      <window_info anchor="bottom" id="Version Control" />
227
+      <window_info anchor="bottom" id="Terminal" />
228
+      <window_info id="Capture Tool" />
229
+      <window_info id="Designer" />
230
+      <window_info active="true" content_ui="combo" id="Project" order="0" visible="true" weight="0.24973376" />
231
+      <window_info anchor="right" id="Database" />
232
+      <window_info id="Learn" />
233
+      <window_info id="Structure" order="1" side_tool="true" weight="0.25" />
234
+      <window_info anchor="right" id="Ant Build" order="1" weight="0.25" />
235
+      <window_info id="UI Designer" />
236
+      <window_info anchor="right" id="Theme Preview" />
237
+      <window_info anchor="bottom" id="Debug" order="3" weight="0.4" />
238
+      <window_info id="Favorites" side_tool="true" />
239
+      <window_info anchor="bottom" id="Find" order="1" />
240
+      <window_info anchor="right" id="Commander" internal_type="SLIDING" order="0" type="SLIDING" weight="0.4" />
241
+      <window_info anchor="bottom" id="Inspection" order="5" weight="0.4" />
242
+      <window_info anchor="right" content_ui="combo" id="Hierarchy" order="2" weight="0.25" />
243
+      <window_info anchor="bottom" id="Message" order="0" />
244
+      <window_info anchor="bottom" id="Cvs" order="4" weight="0.25" />
245
+    </layout>
246
+  </component>
247
+  <component name="TypeScriptGeneratedFilesManager">
248
+    <option name="version" value="1" />
249
+  </component>
250
+  <component name="VcsContentAnnotationSettings">
251
+    <option name="myLimit" value="2678400000" />
252
+  </component>
253
+  <component name="editorHistoryManager">
254
+    <entry file="file://$PROJECT_DIR$/CurrencyConverterTest.class">
255
+      <provider selected="true" editor-type-id="text-editor">
256
+        <state>
257
+          <folding>
258
+            <element signature="e#0#1307#0" expanded="true" />
259
+          </folding>
260
+        </state>
261
+      </provider>
262
+    </entry>
263
+    <entry file="file://$PROJECT_DIR$/CurrencyConverter.java">
264
+      <provider selected="true" editor-type-id="text-editor">
265
+        <state relative-caret-position="210">
266
+          <caret line="16" column="5" lean-forward="true" selection-start-line="1" selection-start-column="3" selection-end-line="16" selection-end-column="5" />
267
+        </state>
268
+      </provider>
269
+    </entry>
270
+    <entry file="file://$PROJECT_DIR$/CurrencyConverter.class">
271
+      <provider selected="true" editor-type-id="text-editor">
272
+        <state relative-caret-position="735">
273
+          <caret line="73" column="50" lean-forward="true" selection-start-line="6" selection-start-column="4" selection-end-line="73" selection-end-column="50" />
274
+          <folding>
275
+            <element signature="e#0#1688#0" expanded="true" />
276
+          </folding>
277
+        </state>
278
+      </provider>
279
+    </entry>
280
+  </component>
281
+  <component name="masterDetails">
282
+    <states>
283
+      <state key="ProjectJDKs.UI">
284
+        <settings>
285
+          <last-edited>1.8</last-edited>
286
+          <splitter-proportions>
287
+            <option name="proportions">
288
+              <list>
289
+                <option value="0.2" />
290
+              </list>
291
+            </option>
292
+          </splitter-proportions>
293
+        </settings>
294
+      </state>
295
+    </states>
296
+  </component>
297
+</project>

+ 21
- 0
CurrencyConverter.java Parādīt failu

@@ -1,2 +1,23 @@
1
+import java.util.*;
1 2
 public class CurrencyConverter {
3
+    private Map<String, Double> dollarConv = new HashMap<>();
4
+    public CurrencyConverter() {
5
+        dollarConv.put("DOLLAR", 1.00);
6
+        dollarConv.put("EURO", 0.94);
7
+        dollarConv.put("POUND", 0.82);
8
+        dollarConv.put("RUPEE", 68.32);
9
+        dollarConv.put("AUSDOLLAR", 1.35);
10
+        dollarConv.put("CANDOLLAR", 1.32);
11
+        dollarConv.put("SINGDOLLAR", 1.43);
12
+        dollarConv.put("FRANC", 1.01);
13
+        dollarConv.put("RINGGIT", 4.47);
14
+        dollarConv.put("YEN", 115.84);
15
+        dollarConv.put("RENMINBI", 6.92);
16
+    }
17
+    public double convert(String from, double money, String to) {
18
+        return (money * asDollar(from)) * dollarConv.get(to);
19
+    }
20
+    public double asDollar(String from) {
21
+        return 1 / dollarConv.get(from);
22
+    }
2 23
 }

+ 79
- 0
CurrencyConverterTest.java Parādīt failu

@@ -1,2 +1,81 @@
1
+
2
+
3
+import static org.junit.Assert.*;
4
+import org.junit.After;
5
+import org.junit.Before;
6
+import org.junit.Test;
7
+
1 8
 public class CurrencyConverterTest {
9
+   @Test
10
+   public void testDollarToEuro() {
11
+       CurrencyConverter wuTang = new CurrencyConverter();
12
+       double expected = 23.50;
13
+       double actual = wuTang.convert("DOLLAR", 25.00, "EURO");
14
+       assertEquals(expected, actual, 0.001);
15
+   }
16
+   @Test
17
+   public void testEuroToDollar() {
18
+       CurrencyConverter wuTang = new CurrencyConverter();
19
+       double expected = 25.00;
20
+       double actual = wuTang.convert("EURO", 23.50, "DOLLAR");
21
+       assertEquals(expected, actual, 2);
22
+   }
23
+   @Test
24
+   public void testEuroToPound() {
25
+       CurrencyConverter wuTang = new CurrencyConverter();
26
+       double expected = 23.50;
27
+       double actual = wuTang.convert("EURO", 25.00, "POUND");
28
+       assertEquals(expected, actual, 0.001);
29
+   }
30
+   @Test
31
+   public void testPoundToRupee() {
32
+       CurrencyConverter wuTang = new CurrencyConverter();
33
+       double expected = 23.50;
34
+       double actual = wuTang.convert("POUND", 25.00, "RUPEE");
35
+       assertEquals(expected, actual, 0.001);
36
+   }
37
+   @Test
38
+   public void testRupeeToCANDollar() {
39
+       CurrencyConverter wuTang = new CurrencyConverter();
40
+       double expected = 23.50;
41
+       double actual = wuTang.convert("RUPEE", 25.00, "CANDOLLAR");
42
+       assertEquals(expected, actual, 0.001);
43
+   }
44
+   @Test
45
+   public void testCANDollarToSINGDollar() {
46
+       CurrencyConverter wuTang = new CurrencyConverter();
47
+       double expected = 23.50;
48
+       double actual = wuTang.convert("CANDOLLAR", 25.00, "SINGDOLLAR");
49
+       assertEquals(expected, actual, 0.001);
50
+   }
51
+   @Test
52
+   public void testSINGDollarToFranc() {
53
+       CurrencyConverter wuTang = new CurrencyConverter();
54
+       double expected = 23.50;
55
+       double actual = wuTang.convert("SINGDOLLAR", 25.00, "FRANC");
56
+       assertEquals(expected, actual, 0.001);
57
+   }
58
+   @Test
59
+   public void testFrancToRinggit() {
60
+       CurrencyConverter wuTang = new CurrencyConverter();
61
+       double expected = 23.50;
62
+       double actual = wuTang.convert("FRANC", 25.00, "RINGGIT");
63
+       assertEquals(expected, actual, 0.001);
64
+   }
65
+   @Test
66
+   public void testRinggitToYen() {
67
+       CurrencyConverter wuTang = new CurrencyConverter();
68
+       double expected = 23.50;
69
+       double actual = wuTang.convert("RINGGIT", 25.00, "YEN");
70
+       assertEquals(expected, actual, 0.001);
71
+   }
72
+   @Test
73
+   public void testYenToRenminbi() {
74
+       CurrencyConverter wuTang = new CurrencyConverter();
75
+       double expected = 23.50;
76
+       double actual = wuTang.convert("YEN", 25.00, "RENMINBI");
77
+       assertEquals(expected, actual, 0.001);
78
+   }
79
+   
80
+    
2 81
 }

+ 28
- 10
package.bluej Parādīt failu

@@ -1,20 +1,23 @@
1 1
 #BlueJ package file
2
+dependency1.from=CurrencyConverterTest
3
+dependency1.to=CurrencyConverter
4
+dependency1.type=UsesDependency
2 5
 editor.fx.0.height=722
3 6
 editor.fx.0.width=800
4
-editor.fx.0.x=560
5
-editor.fx.0.y=117
6
-objectbench.height=101
7
-objectbench.width=461
7
+editor.fx.0.x=215
8
+editor.fx.0.y=-1046
9
+objectbench.height=151
10
+objectbench.width=776
8 11
 package.divider.horizontal=0.6
9
-package.divider.vertical=0.8007380073800738
10
-package.editor.height=427
12
+package.divider.vertical=0.7084870848708487
13
+package.editor.height=377
11 14
 package.editor.width=674
12
-package.editor.x=141
13
-package.editor.y=59
15
+package.editor.x=124
16
+package.editor.y=115
14 17
 package.frame.height=600
15 18
 package.frame.width=800
16
-package.numDependencies=0
17
-package.numTargets=0
19
+package.numDependencies=1
20
+package.numTargets=2
18 21
 package.showExtends=true
19 22
 package.showUses=true
20 23
 project.charset=UTF-8
@@ -23,3 +26,18 @@ readme.name=@README
23 26
 readme.width=47
24 27
 readme.x=10
25 28
 readme.y=10
29
+target1.height=50
30
+target1.name=CurrencyConverterTest
31
+target1.showInterface=false
32
+target1.type=UnitTestTargetJunit4
33
+target1.width=140
34
+target1.x=40
35
+target1.y=90
36
+target2.association=CurrencyConverterTest
37
+target2.height=50
38
+target2.name=CurrencyConverter
39
+target2.showInterface=false
40
+target2.type=ClassTarget
41
+target2.width=140
42
+target2.x=10
43
+target2.y=120