Seth 6 years ago
parent
commit
54daf520b6

+ 99
- 62
.idea/workspace.xml View File

@@ -4,7 +4,9 @@
4 4
     <list default="true" id="b71a0d05-772d-4338-8f47-61b6a36d5d57" name="Default Changelist" comment="">
5 5
       <change beforePath="$PROJECT_DIR$/src/main/java/AccountApp.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/AccountApp.java" afterDir="false" />
6 6
       <change beforePath="$PROJECT_DIR$/src/main/java/AccountServ.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/AccountServ.java" afterDir="false" />
7
+      <change beforePath="$PROJECT_DIR$/src/main/java/Console.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/Console.java" afterDir="false" />
7 8
       <change beforePath="$PROJECT_DIR$/src/test/java/AccountServTest.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/test/java/AccountServTest.java" afterDir="false" />
9
+      <change beforePath="$PROJECT_DIR$/src/test/java/MockDao.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/test/java/MockDao.java" afterDir="false" />
8 10
     </list>
9 11
     <ignored path="$PROJECT_DIR$/target/" />
10 12
     <option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
@@ -45,12 +47,12 @@
45 47
       </usages-collector>
46 48
       <usages-collector id="statistics.file.extensions.edit">
47 49
         <counts>
48
-          <entry key="java" value="2021" />
50
+          <entry key="java" value="3791" />
49 51
         </counts>
50 52
       </usages-collector>
51 53
       <usages-collector id="statistics.file.types.edit">
52 54
         <counts>
53
-          <entry key="JAVA" value="2021" />
55
+          <entry key="JAVA" value="3791" />
54 56
         </counts>
55 57
       </usages-collector>
56 58
     </session>
@@ -60,7 +62,7 @@
60 62
       <file pinned="false" current-in-tab="false">
61 63
         <entry file="file://$PROJECT_DIR$/src/main/java/Account.java">
62 64
           <provider selected="true" editor-type-id="text-editor">
63
-            <state relative-caret-position="55">
65
+            <state relative-caret-position="-288">
64 66
               <caret line="5" column="13" selection-start-line="5" selection-start-column="13" selection-end-line="5" selection-end-column="13" />
65 67
             </state>
66 68
           </provider>
@@ -69,8 +71,8 @@
69 71
       <file pinned="false" current-in-tab="false">
70 72
         <entry file="file://$PROJECT_DIR$/src/test/java/MockDao.java">
71 73
           <provider selected="true" editor-type-id="text-editor">
72
-            <state relative-caret-position="516">
73
-              <caret line="37" column="12" selection-start-line="37" selection-start-column="10" selection-end-line="37" selection-end-column="12" />
74
+            <state relative-caret-position="240">
75
+              <caret line="32" selection-start-line="32" selection-end-line="32" />
74 76
               <folding>
75 77
                 <element signature="imports" expanded="true" />
76 78
                 <element signature="e#1718#1719#0" expanded="true" />
@@ -84,11 +86,11 @@
84 86
           </provider>
85 87
         </entry>
86 88
       </file>
87
-      <file pinned="false" current-in-tab="true">
89
+      <file pinned="false" current-in-tab="false">
88 90
         <entry file="file://$PROJECT_DIR$/src/test/java/AccountServTest.java">
89 91
           <provider selected="true" editor-type-id="text-editor">
90
-            <state relative-caret-position="285">
91
-              <caret line="25" column="5" lean-forward="true" selection-start-line="25" selection-start-column="5" selection-end-line="25" selection-end-column="5" />
92
+            <state relative-caret-position="148">
93
+              <caret line="37" column="31" selection-start-line="37" selection-start-column="31" selection-end-line="37" selection-end-column="31" />
92 94
             </state>
93 95
           </provider>
94 96
         </entry>
@@ -96,8 +98,8 @@
96 98
       <file pinned="false" current-in-tab="false">
97 99
         <entry file="file://$PROJECT_DIR$/src/main/java/AccountApp.java">
98 100
           <provider selected="true" editor-type-id="text-editor">
99
-            <state relative-caret-position="248">
100
-              <caret line="47" column="49" selection-start-line="47" selection-start-column="49" selection-end-line="47" selection-end-column="49" />
101
+            <state relative-caret-position="293">
102
+              <caret line="54" column="57" selection-start-line="54" selection-start-column="57" selection-end-line="54" selection-end-column="57" />
101 103
               <folding>
102 104
                 <element signature="imports" expanded="true" />
103 105
               </folding>
@@ -105,11 +107,11 @@
105 107
           </provider>
106 108
         </entry>
107 109
       </file>
108
-      <file pinned="false" current-in-tab="false">
110
+      <file pinned="false" current-in-tab="true">
109 111
         <entry file="file://$PROJECT_DIR$/src/main/java/AccountServ.java">
110 112
           <provider selected="true" editor-type-id="text-editor">
111
-            <state relative-caret-position="255">
112
-              <caret line="17" column="28" lean-forward="true" selection-start-line="17" selection-start-column="28" selection-end-line="17" selection-end-column="28" />
113
+            <state relative-caret-position="225">
114
+              <caret line="35" column="40" selection-start-line="35" selection-start-column="40" selection-end-line="35" selection-end-column="40" />
113 115
               <folding>
114 116
                 <element signature="imports" expanded="true" />
115 117
                 <element signature="e#175#176#0" expanded="true" />
@@ -122,9 +124,11 @@
122 124
       <file pinned="false" current-in-tab="false">
123 125
         <entry file="file://$PROJECT_DIR$/src/main/java/Console.java">
124 126
           <provider selected="true" editor-type-id="text-editor">
125
-            <state relative-caret-position="435">
126
-              <caret line="29" column="30" selection-start-line="29" selection-start-column="30" selection-end-line="29" selection-end-column="30" />
127
+            <state relative-caret-position="307">
128
+              <caret line="47" column="1" lean-forward="true" selection-start-line="47" selection-start-column="1" selection-end-line="47" selection-end-column="1" />
127 129
               <folding>
130
+                <element signature="e#317#318#0" expanded="true" />
131
+                <element signature="e#345#346#0" expanded="true" />
128 132
                 <element signature="e#135#136#0" expanded="true" />
129 133
                 <element signature="e#169#170#0" expanded="true" />
130 134
                 <element signature="e#213#214#0" expanded="true" />
@@ -157,6 +161,8 @@
157 161
       <find>UPDATE</find>
158 162
       <find>upda</find>
159 163
       <find>id</find>
164
+      <find>updat</find>
165
+      <find>public</find>
160 166
     </findStrings>
161 167
   </component>
162 168
   <component name="Git.Settings">
@@ -166,10 +172,10 @@
166 172
     <option name="CHANGED_PATHS">
167 173
       <list>
168 174
         <option value="$PROJECT_DIR$/src/test/java/MockDao.java" />
169
-        <option value="$PROJECT_DIR$/src/main/java/Console.java" />
170
-        <option value="$PROJECT_DIR$/src/main/java/AccountServ.java" />
171 175
         <option value="$PROJECT_DIR$/src/test/java/AccountServTest.java" />
172 176
         <option value="$PROJECT_DIR$/src/main/java/AccountApp.java" />
177
+        <option value="$PROJECT_DIR$/src/main/java/Console.java" />
178
+        <option value="$PROJECT_DIR$/src/main/java/AccountServ.java" />
173 179
       </list>
174 180
     </option>
175 181
   </component>
@@ -239,7 +245,7 @@
239 245
   <component name="PropertiesComponent">
240 246
     <property name="WebServerToolWindowFactoryState" value="false" />
241 247
     <property name="aspect.path.notification.shown" value="true" />
242
-    <property name="com.android.tools.idea.instantapp.provision.ProvisionBeforeRunTaskProvider.myTimeStamp" value="1542566112760" />
248
+    <property name="com.android.tools.idea.instantapp.provision.ProvisionBeforeRunTaskProvider.myTimeStamp" value="1542570976587" />
243 249
     <property name="last_opened_file_path" value="$PROJECT_DIR$" />
244 250
     <property name="nodejs_interpreter_path.stuck_in_default_project" value="undefined stuck path" />
245 251
     <property name="nodejs_npm_path_reset_for_default_project" value="true" />
@@ -260,7 +266,7 @@
260 266
       </list>
261 267
     </option>
262 268
   </component>
263
-  <component name="RunManager" selected="JUnit.AccountServTest.createTest">
269
+  <component name="RunManager" selected="Application.AccountApp">
264 270
     <configuration name="AccountApp" type="Application" factoryName="Application" temporary="true" nameIsGenerated="true">
265 271
       <option name="MAIN_CLASS_NAME" value="AccountApp" />
266 272
       <module name="SimpleAccount" />
@@ -278,14 +284,26 @@
278 284
         <option name="Make" enabled="true" />
279 285
       </method>
280 286
     </configuration>
287
+    <configuration name="AccountServTest.readTest" type="JUnit" factoryName="JUnit" temporary="true" nameIsGenerated="true">
288
+      <module name="SimpleAccount" />
289
+      <option name="PACKAGE_NAME" value="" />
290
+      <option name="MAIN_CLASS_NAME" value="AccountServTest" />
291
+      <option name="METHOD_NAME" value="readTest" />
292
+      <option name="TEST_OBJECT" value="method" />
293
+      <method v="2">
294
+        <option name="Make" enabled="true" />
295
+      </method>
296
+    </configuration>
281 297
     <list>
282 298
       <item itemvalue="Application.AccountApp" />
283 299
       <item itemvalue="JUnit.AccountServTest.createTest" />
300
+      <item itemvalue="JUnit.AccountServTest.readTest" />
284 301
     </list>
285 302
     <recent_temporary>
286 303
       <list>
287
-        <item itemvalue="JUnit.AccountServTest.createTest" />
288 304
         <item itemvalue="Application.AccountApp" />
305
+        <item itemvalue="JUnit.AccountServTest.readTest" />
306
+        <item itemvalue="JUnit.AccountServTest.createTest" />
289 307
       </list>
290 308
     </recent_temporary>
291 309
   </component>
@@ -302,18 +320,35 @@
302 320
       <workItem from="1542239571129" duration="6414000" />
303 321
       <workItem from="1542402275147" duration="2006000" />
304 322
       <workItem from="1542420139392" duration="4000" />
305
-      <workItem from="1542475891339" duration="7385000" />
323
+      <workItem from="1542475891339" duration="12147000" />
306 324
     </task>
307 325
     <servers />
308 326
   </component>
327
+  <component name="TestHistory">
328
+    <history-entry file="AccountServTest_createTest - 2018.11.18 at 13h 35m 17s.xml">
329
+      <configuration name="AccountServTest.createTest" configurationId="JUnit" />
330
+    </history-entry>
331
+    <history-entry file="AccountServTest_readTest - 2018.11.18 at 13h 55m 58s.xml">
332
+      <configuration name="AccountServTest.readTest" configurationId="JUnit" />
333
+    </history-entry>
334
+    <history-entry file="AccountServTest_readTest - 2018.11.18 at 13h 57m 03s.xml">
335
+      <configuration name="AccountServTest.readTest" configurationId="JUnit" />
336
+    </history-entry>
337
+    <history-entry file="AccountServTest_readTest - 2018.11.18 at 13h 57m 14s.xml">
338
+      <configuration name="AccountServTest.readTest" configurationId="JUnit" />
339
+    </history-entry>
340
+    <history-entry file="AccountServTest_readTest - 2018.11.18 at 13h 57m 20s.xml">
341
+      <configuration name="AccountServTest.readTest" configurationId="JUnit" />
342
+    </history-entry>
343
+  </component>
309 344
   <component name="TimeTrackingManager">
310
-    <option name="totallyTimeSpent" value="15809000" />
345
+    <option name="totallyTimeSpent" value="20571000" />
311 346
   </component>
312 347
   <component name="ToolWindowManager">
313 348
     <frame x="0" y="23" width="1440" height="807" extended-state="0" />
314 349
     <editor active="true" />
315 350
     <layout>
316
-      <window_info active="true" content_ui="combo" id="Project" order="0" visible="true" weight="0.26037195" />
351
+      <window_info content_ui="combo" id="Project" order="0" visible="true" weight="0.26037195" />
317 352
       <window_info id="Structure" order="1" side_tool="true" weight="0.25" />
318 353
       <window_info id="Image Layers" order="2" />
319 354
       <window_info id="Designer" order="3" />
@@ -322,7 +357,7 @@
322 357
       <window_info id="Favorites" order="6" side_tool="true" />
323 358
       <window_info anchor="bottom" id="Message" order="0" />
324 359
       <window_info anchor="bottom" id="Find" order="1" />
325
-      <window_info anchor="bottom" id="Run" order="2" weight="0.32867134" />
360
+      <window_info active="true" anchor="bottom" id="Run" order="2" sideWeight="0.49928468" visible="true" weight="0.4797203" />
326 361
       <window_info anchor="bottom" id="Debug" order="3" weight="0.4" />
327 362
       <window_info anchor="bottom" id="Cvs" order="4" weight="0.25" />
328 363
       <window_info anchor="bottom" id="Inspection" order="5" weight="0.4" />
@@ -330,7 +365,7 @@
330 365
       <window_info anchor="bottom" id="Version Control" order="7" show_stripe_button="false" />
331 366
       <window_info anchor="bottom" id="Database Changes" order="8" show_stripe_button="false" />
332 367
       <window_info anchor="bottom" id="Terminal" order="9" />
333
-      <window_info anchor="bottom" id="Event Log" order="10" side_tool="true" />
368
+      <window_info anchor="bottom" id="Event Log" order="10" sideWeight="0.5007153" side_tool="true" weight="0.32867134" />
334 369
       <window_info anchor="bottom" id="Messages" order="11" weight="0.32867134" />
335 370
       <window_info anchor="right" id="Commander" internal_type="SLIDING" order="0" type="SLIDING" weight="0.4" />
336 371
       <window_info anchor="right" id="Ant Build" order="1" weight="0.25" />
@@ -382,46 +417,17 @@
382 417
         </state>
383 418
       </provider>
384 419
     </entry>
385
-    <entry file="file://$PROJECT_DIR$/src/main/java/Console.java">
386
-      <provider selected="true" editor-type-id="text-editor">
387
-        <state relative-caret-position="435">
388
-          <caret line="29" column="30" selection-start-line="29" selection-start-column="30" selection-end-line="29" selection-end-column="30" />
389
-          <folding>
390
-            <element signature="e#135#136#0" expanded="true" />
391
-            <element signature="e#169#170#0" expanded="true" />
392
-            <element signature="e#213#214#0" expanded="true" />
393
-            <element signature="e#241#242#0" expanded="true" />
394
-            <element signature="e#273#274#0" expanded="true" />
395
-            <element signature="e#286#287#0" expanded="true" />
396
-            <element signature="e#331#332#0" expanded="true" />
397
-            <element signature="e#353#354#0" expanded="true" />
398
-          </folding>
399
-        </state>
400
-      </provider>
401
-    </entry>
402 420
     <entry file="file://$PROJECT_DIR$/src/main/java/Account.java">
403 421
       <provider selected="true" editor-type-id="text-editor">
404
-        <state relative-caret-position="55">
422
+        <state relative-caret-position="-288">
405 423
           <caret line="5" column="13" selection-start-line="5" selection-start-column="13" selection-end-line="5" selection-end-column="13" />
406 424
         </state>
407 425
       </provider>
408 426
     </entry>
409
-    <entry file="file://$PROJECT_DIR$/src/main/java/AccountServ.java">
410
-      <provider selected="true" editor-type-id="text-editor">
411
-        <state relative-caret-position="255">
412
-          <caret line="17" column="28" lean-forward="true" selection-start-line="17" selection-start-column="28" selection-end-line="17" selection-end-column="28" />
413
-          <folding>
414
-            <element signature="imports" expanded="true" />
415
-            <element signature="e#175#176#0" expanded="true" />
416
-            <element signature="e#203#204#0" expanded="true" />
417
-          </folding>
418
-        </state>
419
-      </provider>
420
-    </entry>
421 427
     <entry file="file://$PROJECT_DIR$/src/test/java/MockDao.java">
422 428
       <provider selected="true" editor-type-id="text-editor">
423
-        <state relative-caret-position="516">
424
-          <caret line="37" column="12" selection-start-line="37" selection-start-column="10" selection-end-line="37" selection-end-column="12" />
429
+        <state relative-caret-position="240">
430
+          <caret line="32" selection-start-line="32" selection-end-line="32" />
425 431
           <folding>
426 432
             <element signature="imports" expanded="true" />
427 433
             <element signature="e#1718#1719#0" expanded="true" />
@@ -434,20 +440,51 @@
434 440
         </state>
435 441
       </provider>
436 442
     </entry>
443
+    <entry file="file://$PROJECT_DIR$/src/test/java/AccountServTest.java">
444
+      <provider selected="true" editor-type-id="text-editor">
445
+        <state relative-caret-position="148">
446
+          <caret line="37" column="31" selection-start-line="37" selection-start-column="31" selection-end-line="37" selection-end-column="31" />
447
+        </state>
448
+      </provider>
449
+    </entry>
437 450
     <entry file="file://$PROJECT_DIR$/src/main/java/AccountApp.java">
438 451
       <provider selected="true" editor-type-id="text-editor">
439
-        <state relative-caret-position="248">
440
-          <caret line="47" column="49" selection-start-line="47" selection-start-column="49" selection-end-line="47" selection-end-column="49" />
452
+        <state relative-caret-position="293">
453
+          <caret line="54" column="57" selection-start-line="54" selection-start-column="57" selection-end-line="54" selection-end-column="57" />
441 454
           <folding>
442 455
             <element signature="imports" expanded="true" />
443 456
           </folding>
444 457
         </state>
445 458
       </provider>
446 459
     </entry>
447
-    <entry file="file://$PROJECT_DIR$/src/test/java/AccountServTest.java">
460
+    <entry file="file://$PROJECT_DIR$/src/main/java/Console.java">
448 461
       <provider selected="true" editor-type-id="text-editor">
449
-        <state relative-caret-position="285">
450
-          <caret line="25" column="5" lean-forward="true" selection-start-line="25" selection-start-column="5" selection-end-line="25" selection-end-column="5" />
462
+        <state relative-caret-position="307">
463
+          <caret line="47" column="1" lean-forward="true" selection-start-line="47" selection-start-column="1" selection-end-line="47" selection-end-column="1" />
464
+          <folding>
465
+            <element signature="e#317#318#0" expanded="true" />
466
+            <element signature="e#345#346#0" expanded="true" />
467
+            <element signature="e#135#136#0" expanded="true" />
468
+            <element signature="e#169#170#0" expanded="true" />
469
+            <element signature="e#213#214#0" expanded="true" />
470
+            <element signature="e#241#242#0" expanded="true" />
471
+            <element signature="e#273#274#0" expanded="true" />
472
+            <element signature="e#286#287#0" expanded="true" />
473
+            <element signature="e#331#332#0" expanded="true" />
474
+            <element signature="e#353#354#0" expanded="true" />
475
+          </folding>
476
+        </state>
477
+      </provider>
478
+    </entry>
479
+    <entry file="file://$PROJECT_DIR$/src/main/java/AccountServ.java">
480
+      <provider selected="true" editor-type-id="text-editor">
481
+        <state relative-caret-position="225">
482
+          <caret line="35" column="40" selection-start-line="35" selection-start-column="40" selection-end-line="35" selection-end-column="40" />
483
+          <folding>
484
+            <element signature="imports" expanded="true" />
485
+            <element signature="e#175#176#0" expanded="true" />
486
+            <element signature="e#203#204#0" expanded="true" />
487
+          </folding>
451 488
         </state>
452 489
       </provider>
453 490
     </entry>

+ 17
- 14
src/main/java/AccountApp.java View File

@@ -25,8 +25,7 @@ import com.j256.ormlite.support.ConnectionSource;
25 25
                 connectionSource = new JdbcConnectionSource(DATABASE_URL, YOURUSERNAME, YOURPASSWORD);
26 26
                 setupDao(connectionSource);
27 27
                 processData();
28
-
29
-                System.out.println("\n\nIt seems to have worked\n\n");
28
+                console.print("Have a nice day");
30 29
             } finally {
31 30
                 // destroy the data source which should close underlying connections
32 31
                 if (connectionSource != null) {
@@ -39,24 +38,28 @@ import com.j256.ormlite.support.ConnectionSource;
39 38
          * Read and write some example data.
40 39
          */
41 40
         private void processData() throws Exception {
42
-           AccountServ services = new AccountServ();
41
+           AccountServ services = new AccountServ(accountDao);
43 42
            boolean end = false;
44 43
             console.print("Welcome to your account manager");
45 44
                 while(!end){
45
+                    console.printMenu();
46 46
                    int input = console.prntTakeInt("Please enter your selection: ");
47
-                    if (input == 1) {
48
-                        services.createAccount();
49
-                    } else if(input == 2) {
50
-
51
-                    } else if(input == 3) {
47
+                   switch (input) {
48
+                       case 1 : services.createAccount();
49
+                       break;
50
+                       case 2 : int id = console.idCheck();
51
+                       services.accountString(id);
52
+                       break;
53
+                       case 3 : services.updateAccount();
54
+                       break;
55
+                       case 4 : services.deleteAccount();
56
+                           break;
57
+                       case 5 : end = true; break;
58
+                       default: console.invalid();
59
+                            console.printMenu();
60
+                   }
52 61
 
53
-                    } else if(input == 4) {
54
-
55
-                    } else {
56
-                        end = true;
57
-                    }
58 62
                 }
59
-
60 63
         }
61 64
 
62 65
         /**

+ 34
- 5
src/main/java/AccountServ.java View File

@@ -7,7 +7,7 @@ public class AccountServ {
7 7
     private Dao<Account, Integer> dao;
8 8
     private Console console = new Console();
9 9
 
10
-    public AccountServ() {
10
+    public AccountServ(Dao<Account, Integer> dao) {
11 11
         this.dao = dao;
12 12
     }
13 13
 
@@ -18,7 +18,7 @@ public class AccountServ {
18 18
         dao.create(account);
19 19
     }
20 20
 
21
-    public int create(Account account) throws SQLException {
21
+    private int create(Account account) throws SQLException {
22 22
         return dao.create(account);
23 23
     }
24 24
 
@@ -26,18 +26,47 @@ public class AccountServ {
26 26
         return dao.queryForId(id);
27 27
     }
28 28
 
29
+    public void accountString(int id) throws SQLException{
30
+       Account account =  read(id);
31
+       console.print("\n" + account.getName() + " " + account.getPassword() + "\n");
32
+    }
33
+
34
+    private Account getAcccount()throws SQLException {
35
+        String input = console.prntTakeStr("Enter your account ID");
36
+        return read(Integer.parseInt(input));
37
+    }
29 38
 
30
-    public void setPassword(Account account, String password) throws SQLException {
39
+    public void updateAccount() throws SQLException {
40
+        Account account = getAcccount();
41
+        int input = console.prntTakeInt("Enter 1 to change account password or 2 to change account name");
42
+        if(input == 1) {setPassword(account);}
43
+            else if (input == 2){
44
+                setName(account);}
45
+            else {console.invalid();}
46
+    }
47
+
48
+    private void setPassword(Account account) throws SQLException {
49
+        String password =  console.prntTakeStr("Enter new password");
31 50
         account.setPassword(password);
32 51
         dao.update(account);
33 52
     }
34 53
 
35
-    public void setName(Account account, String name) throws SQLException {
54
+    private void setName(Account account) throws SQLException {
55
+        String name = console.prntTakeStr("Enter new name");
36 56
         account.setName(name);
37 57
         dao.update(account);
38 58
     }
39 59
 
40
-    public int delete(Account account) throws SQLException {
60
+    public void deleteAccount() throws SQLException{
61
+        Account account = getAcccount();
62
+        String input =  console.prntTakeStr("Are you sure you would like to delete your account?\nY / N");
63
+        if (input.equalsIgnoreCase("y")){
64
+            delete(account);
65
+            console.print("Account deleted");
66
+        } else {}
67
+    }
68
+
69
+    private int delete(Account account) throws SQLException {
41 70
         return dao.delete(account);
42 71
     }
43 72
 

+ 17
- 1
src/main/java/Console.java View File

@@ -4,6 +4,15 @@ public class Console {
4 4
 
5 5
 private Scanner scanner = new Scanner(System.in);
6 6
 
7
+public void printMenu() {
8
+    System.out.println("Selection menu: \n 1. Create New Account\n 2. Check Account Info\n 3. Change Account Info\n" +
9
+            " 4. Delete Account\n 5. Quit");
10
+}
11
+
12
+public void invalid() {
13
+    System.out.println("Invalid Entry. Please try again");
14
+}
15
+
7 16
 public void print(String string) {
8 17
     System.out.println(string);
9 18
 }
@@ -27,6 +36,13 @@ public int prntTakeInt(String output) {
27 36
 
28 37
 public String prntTakeStr(String output) {
29 38
     System.out.println(output);
30
-    return scanner.nextLine();
39
+    return scanner.next();
31 40
 }
41
+
42
+public int idCheck() {
43
+    System.out.println("Enter your Account ID");
44
+    return scanner.nextInt();
45
+}
46
+
47
+
32 48
 }

+ 7
- 2
src/test/java/AccountServTest.java View File

@@ -10,11 +10,13 @@ public class AccountServTest {
10 10
 
11 11
     Dao<Account, Integer> dao;
12 12
     Account account;
13
+    AccountServ test;
13 14
 
14 15
     @Before
15 16
     public void setup() {
16 17
         dao = new MockDao();
17
-        account = new Account();
18
+        test = new AccountServ(dao);
19
+        account = new Account("Bob", "password");
18 20
     }
19 21
 
20 22
     @Test
@@ -32,8 +34,11 @@ public class AccountServTest {
32 34
     }
33 35
 
34 36
     @Test
35
-    public void readTest(){
37
+    public void readTest() throws SQLException{
38
+        Account expected = test.read(0);
39
+        Account actual = dao.queryForId(0);
36 40
 
41
+        Assert.assertEquals(expected, actual);
37 42
     }
38 43
 
39 44
     @Test

+ 2
- 1
src/test/java/MockDao.java View File

@@ -14,6 +14,7 @@ import java.util.Map;
14 14
 import java.util.concurrent.Callable;
15 15
 
16 16
 public class MockDao implements Dao<Account, Integer> {
17
+    Account account = new Account("Bob", "password");
17 18
 
18 19
     @Override
19 20
     public int create(Account account) throws SQLException {
@@ -32,7 +33,7 @@ public class MockDao implements Dao<Account, Integer> {
32 33
 
33 34
     @Override
34 35
     public Account queryForId(Integer integer) throws SQLException {
35
-        return null;
36
+        return account;
36 37
     }
37 38
 
38 39
     @Override

BIN
target/classes/AccountApp.class View File


BIN
target/classes/AccountServ.class View File


BIN
target/classes/Console.class View File


BIN
target/test-classes/AccountServTest.class View File


BIN
target/test-classes/MockDao.class View File