Browse Source

controlloopstub

Seth 6 years ago
parent
commit
da21513355
4 changed files with 83 additions and 70 deletions
  1. 47
    54
      .idea/workspace.xml
  2. 19
    14
      src/main/java/AccountApp.java
  3. 9
    2
      src/main/java/AccountServ.java
  4. 8
    0
      src/main/java/Console.java

+ 47
- 54
.idea/workspace.xml View File

@@ -2,8 +2,9 @@
2 2
 <project version="4">
3 3
   <component name="ChangeListManager">
4 4
     <list default="true" id="b71a0d05-772d-4338-8f47-61b6a36d5d57" name="Default Changelist" comment="">
5
-      <change afterPath="$PROJECT_DIR$/src/main/java/Console.java" afterDir="false" />
6
-      <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
5
+      <change beforePath="$PROJECT_DIR$/src/main/java/AccountApp.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/AccountApp.java" afterDir="false" />
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
     </list>
8 9
     <ignored path="$PROJECT_DIR$/target/" />
9 10
     <option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
@@ -44,12 +45,12 @@
44 45
       </usages-collector>
45 46
       <usages-collector id="statistics.file.extensions.edit">
46 47
         <counts>
47
-          <entry key="java" value="817" />
48
+          <entry key="java" value="1425" />
48 49
         </counts>
49 50
       </usages-collector>
50 51
       <usages-collector id="statistics.file.types.edit">
51 52
         <counts>
52
-          <entry key="JAVA" value="817" />
53
+          <entry key="JAVA" value="1425" />
53 54
         </counts>
54 55
       </usages-collector>
55 56
     </session>
@@ -59,7 +60,7 @@
59 60
       <file pinned="false" current-in-tab="false">
60 61
         <entry file="file://$PROJECT_DIR$/src/main/java/Account.java">
61 62
           <provider selected="true" editor-type-id="text-editor">
62
-            <state relative-caret-position="-112">
63
+            <state relative-caret-position="55">
63 64
               <caret line="5" column="13" selection-start-line="5" selection-start-column="13" selection-end-line="5" selection-end-column="13" />
64 65
             </state>
65 66
           </provider>
@@ -68,8 +69,8 @@
68 69
       <file pinned="false" current-in-tab="false">
69 70
         <entry file="file://$PROJECT_DIR$/src/test/java/MockDao.java">
70 71
           <provider selected="true" editor-type-id="text-editor">
71
-            <state relative-caret-position="319">
72
-              <caret line="28" column="19" lean-forward="true" selection-start-line="28" selection-start-column="19" selection-end-line="28" selection-end-column="19" />
72
+            <state relative-caret-position="-1666">
73
+              <caret line="37" column="12" selection-start-line="37" selection-start-column="10" selection-end-line="37" selection-end-column="12" />
73 74
               <folding>
74 75
                 <element signature="imports" expanded="true" />
75 76
                 <element signature="e#1718#1719#0" expanded="true" />
@@ -92,11 +93,11 @@
92 93
           </provider>
93 94
         </entry>
94 95
       </file>
95
-      <file pinned="false" current-in-tab="false">
96
+      <file pinned="false" current-in-tab="true">
96 97
         <entry file="file://$PROJECT_DIR$/src/main/java/AccountApp.java">
97 98
           <provider selected="true" editor-type-id="text-editor">
98
-            <state relative-caret-position="368">
99
-              <caret line="50" column="23" selection-start-line="50" selection-start-column="23" selection-end-line="50" selection-end-column="23" />
99
+            <state relative-caret-position="188">
100
+              <caret line="45" column="24" lean-forward="true" selection-start-line="45" selection-start-column="24" selection-end-line="45" selection-end-column="24" />
100 101
               <folding>
101 102
                 <element signature="imports" expanded="true" />
102 103
               </folding>
@@ -107,8 +108,8 @@
107 108
       <file pinned="false" current-in-tab="false">
108 109
         <entry file="file://$PROJECT_DIR$/src/main/java/AccountServ.java">
109 110
           <provider selected="true" editor-type-id="text-editor">
110
-            <state relative-caret-position="375">
111
-              <caret line="25" column="35" selection-start-line="25" selection-start-column="35" selection-end-line="25" selection-end-column="35" />
111
+            <state relative-caret-position="450">
112
+              <caret line="30" lean-forward="true" selection-start-line="30" selection-end-line="30" />
112 113
               <folding>
113 114
                 <element signature="imports" expanded="true" />
114 115
                 <element signature="e#175#176#0" expanded="true" />
@@ -118,11 +119,11 @@
118 119
           </provider>
119 120
         </entry>
120 121
       </file>
121
-      <file pinned="false" current-in-tab="true">
122
+      <file pinned="false" current-in-tab="false">
122 123
         <entry file="file://$PROJECT_DIR$/src/main/java/Console.java">
123 124
           <provider selected="true" editor-type-id="text-editor">
124
-            <state relative-caret-position="330">
125
-              <caret line="22" lean-forward="true" selection-start-line="22" selection-end-line="22" />
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" />
126 127
               <folding>
127 128
                 <element signature="e#135#136#0" expanded="true" />
128 129
                 <element signature="e#169#170#0" expanded="true" />
@@ -137,15 +138,6 @@
137 138
           </provider>
138 139
         </entry>
139 140
       </file>
140
-      <file pinned="false" current-in-tab="false">
141
-        <entry file="file://$PROJECT_DIR$/SimpleAccount.iml">
142
-          <provider selected="true" editor-type-id="text-editor">
143
-            <state relative-caret-position="270">
144
-              <caret line="20" column="9" selection-start-line="20" selection-start-column="9" selection-end-line="20" selection-end-column="9" />
145
-            </state>
146
-          </provider>
147
-        </entry>
148
-      </file>
149 141
     </leaf>
150 142
   </component>
151 143
   <component name="FileTemplateManagerImpl">
@@ -164,6 +156,7 @@
164 156
       <find>dele</find>
165 157
       <find>UPDATE</find>
166 158
       <find>upda</find>
159
+      <find>id</find>
167 160
     </findStrings>
168 161
   </component>
169 162
   <component name="Git.Settings">
@@ -173,10 +166,10 @@
173 166
     <option name="CHANGED_PATHS">
174 167
       <list>
175 168
         <option value="$PROJECT_DIR$/src/test/java/AccountServTest.java" />
176
-        <option value="$PROJECT_DIR$/src/main/java/AccountApp.java" />
177 169
         <option value="$PROJECT_DIR$/src/test/java/MockDao.java" />
178 170
         <option value="$PROJECT_DIR$/src/main/java/AccountServ.java" />
179 171
         <option value="$PROJECT_DIR$/src/main/java/Console.java" />
172
+        <option value="$PROJECT_DIR$/src/main/java/AccountApp.java" />
180 173
       </list>
181 174
     </option>
182 175
   </component>
@@ -246,7 +239,7 @@
246 239
   <component name="PropertiesComponent">
247 240
     <property name="WebServerToolWindowFactoryState" value="false" />
248 241
     <property name="aspect.path.notification.shown" value="true" />
249
-    <property name="com.android.tools.idea.instantapp.provision.ProvisionBeforeRunTaskProvider.myTimeStamp" value="1542484750730" />
242
+    <property name="com.android.tools.idea.instantapp.provision.ProvisionBeforeRunTaskProvider.myTimeStamp" value="1542565159357" />
250 243
     <property name="last_opened_file_path" value="$PROJECT_DIR$" />
251 244
     <property name="nodejs_interpreter_path.stuck_in_default_project" value="undefined stuck path" />
252 245
     <property name="nodejs_npm_path_reset_for_default_project" value="true" />
@@ -294,12 +287,12 @@
294 287
       <workItem from="1542239571129" duration="6414000" />
295 288
       <workItem from="1542402275147" duration="2006000" />
296 289
       <workItem from="1542420139392" duration="4000" />
297
-      <workItem from="1542475891339" duration="3289000" />
290
+      <workItem from="1542475891339" duration="6221000" />
298 291
     </task>
299 292
     <servers />
300 293
   </component>
301 294
   <component name="TimeTrackingManager">
302
-    <option name="totallyTimeSpent" value="11713000" />
295
+    <option name="totallyTimeSpent" value="14645000" />
303 296
   </component>
304 297
   <component name="ToolWindowManager">
305 298
     <frame x="0" y="23" width="1440" height="807" extended-state="0" />
@@ -360,13 +353,6 @@
360 353
         </state>
361 354
       </provider>
362 355
     </entry>
363
-    <entry file="file://$PROJECT_DIR$/src/main/java/Account.java">
364
-      <provider selected="true" editor-type-id="text-editor">
365
-        <state relative-caret-position="-112">
366
-          <caret line="5" column="13" selection-start-line="5" selection-start-column="13" selection-end-line="5" selection-end-column="13" />
367
-        </state>
368
-      </provider>
369
-    </entry>
370 356
     <entry file="jar://$MAVEN_REPOSITORY$/com/j256/ormlite/ormlite-core/4.48/ormlite-core-4.48.jar!/com/j256/ormlite/stmt/PreparedUpdate.class">
371 357
       <provider selected="true" editor-type-id="text-editor">
372 358
         <state relative-caret-position="60">
@@ -381,20 +367,24 @@
381 367
         </state>
382 368
       </provider>
383 369
     </entry>
384
-    <entry file="file://$PROJECT_DIR$/src/main/java/AccountApp.java">
370
+    <entry file="file://$PROJECT_DIR$/src/main/java/Account.java">
385 371
       <provider selected="true" editor-type-id="text-editor">
386
-        <state relative-caret-position="368">
387
-          <caret line="50" column="23" selection-start-line="50" selection-start-column="23" selection-end-line="50" selection-end-column="23" />
388
-          <folding>
389
-            <element signature="imports" expanded="true" />
390
-          </folding>
372
+        <state relative-caret-position="55">
373
+          <caret line="5" column="13" selection-start-line="5" selection-start-column="13" selection-end-line="5" selection-end-column="13" />
374
+        </state>
375
+      </provider>
376
+    </entry>
377
+    <entry file="file://$PROJECT_DIR$/src/test/java/AccountServTest.java">
378
+      <provider selected="true" editor-type-id="text-editor">
379
+        <state relative-caret-position="480">
380
+          <caret line="35" selection-start-line="35" selection-end-line="35" />
391 381
         </state>
392 382
       </provider>
393 383
     </entry>
394 384
     <entry file="file://$PROJECT_DIR$/src/test/java/MockDao.java">
395 385
       <provider selected="true" editor-type-id="text-editor">
396
-        <state relative-caret-position="319">
397
-          <caret line="28" column="19" lean-forward="true" selection-start-line="28" selection-start-column="19" selection-end-line="28" selection-end-column="19" />
386
+        <state relative-caret-position="-1666">
387
+          <caret line="37" column="12" selection-start-line="37" selection-start-column="10" selection-end-line="37" selection-end-column="12" />
398 388
           <folding>
399 389
             <element signature="imports" expanded="true" />
400 390
             <element signature="e#1718#1719#0" expanded="true" />
@@ -407,17 +397,10 @@
407 397
         </state>
408 398
       </provider>
409 399
     </entry>
410
-    <entry file="file://$PROJECT_DIR$/src/test/java/AccountServTest.java">
411
-      <provider selected="true" editor-type-id="text-editor">
412
-        <state relative-caret-position="480">
413
-          <caret line="35" selection-start-line="35" selection-end-line="35" />
414
-        </state>
415
-      </provider>
416
-    </entry>
417 400
     <entry file="file://$PROJECT_DIR$/src/main/java/AccountServ.java">
418 401
       <provider selected="true" editor-type-id="text-editor">
419
-        <state relative-caret-position="375">
420
-          <caret line="25" column="35" selection-start-line="25" selection-start-column="35" selection-end-line="25" selection-end-column="35" />
402
+        <state relative-caret-position="450">
403
+          <caret line="30" lean-forward="true" selection-start-line="30" selection-end-line="30" />
421 404
           <folding>
422 405
             <element signature="imports" expanded="true" />
423 406
             <element signature="e#175#176#0" expanded="true" />
@@ -428,8 +411,8 @@
428 411
     </entry>
429 412
     <entry file="file://$PROJECT_DIR$/src/main/java/Console.java">
430 413
       <provider selected="true" editor-type-id="text-editor">
431
-        <state relative-caret-position="330">
432
-          <caret line="22" lean-forward="true" selection-start-line="22" selection-end-line="22" />
414
+        <state relative-caret-position="435">
415
+          <caret line="29" column="30" selection-start-line="29" selection-start-column="30" selection-end-line="29" selection-end-column="30" />
433 416
           <folding>
434 417
             <element signature="e#135#136#0" expanded="true" />
435 418
             <element signature="e#169#170#0" expanded="true" />
@@ -443,6 +426,16 @@
443 426
         </state>
444 427
       </provider>
445 428
     </entry>
429
+    <entry file="file://$PROJECT_DIR$/src/main/java/AccountApp.java">
430
+      <provider selected="true" editor-type-id="text-editor">
431
+        <state relative-caret-position="188">
432
+          <caret line="45" column="24" lean-forward="true" selection-start-line="45" selection-start-column="24" selection-end-line="45" selection-end-column="24" />
433
+          <folding>
434
+            <element signature="imports" expanded="true" />
435
+          </folding>
436
+        </state>
437
+      </provider>
438
+    </entry>
446 439
   </component>
447 440
   <component name="masterDetails">
448 441
     <states>

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

@@ -5,10 +5,12 @@ import com.j256.ormlite.support.ConnectionSource;
5 5
 
6 6
     public class AccountApp {
7 7
 
8
+
8 9
         // we are using a MySQl database
9 10
         private final static String DATABASE_URL = "jdbc:mysql://localhost:3306/orm_lab?useUnicode=true";
10 11
         private final static String YOURUSERNAME = "root";
11 12
         private final static String YOURPASSWORD = "";
13
+        private Console console = new Console();
12 14
 
13 15
         private Dao<Account, Integer> accountDao;
14 16
 
@@ -37,20 +39,23 @@ import com.j256.ormlite.support.ConnectionSource;
37 39
          * Read and write some example data.
38 40
          */
39 41
         private void processData() throws Exception {
40
-            // create an instance of Account
41
-            String name = "Jim Coakley";
42
-            Account account = new Account(name);
43
-
44
-            // persist the account object to the database
45
-            accountDao.create(account);
46
-            int id = account.getId();
47
-            System.out.println(id);
48
-            // assign a password
49
-            account.setPassword("_secret");
50
-            // update the database after changing the object
51
-            accountDao.update(account);
52
-            // delete the account
53
-            //accountDao.deleteById(id);
42
+           boolean end = false;
43
+            console.print("Welcome to your account manager");
44
+                while(!end){
45
+                   int input = console.prntTakeInt("Please enter your selection: ");
46
+                    if (input == 1) {
47
+
48
+                    } else if(input == 2) {
49
+
50
+                    } else if(input == 3) {
51
+
52
+                    } else if(input == 4) {
53
+
54
+                    } else {
55
+                        end = true;
56
+                    }
57
+                }
58
+
54 59
         }
55 60
 
56 61
         /**

+ 9
- 2
src/main/java/AccountServ.java View File

@@ -18,8 +18,15 @@ public class AccountServ {
18 18
         return dao.queryForId(id);
19 19
     }
20 20
 
21
-    public int update(Account account) throws SQLException {
22
-        return dao.update(account);
21
+
22
+    public void setPassword(Account account, String password) throws SQLException {
23
+        account.setPassword(password);
24
+        dao.update(account);
25
+    }
26
+
27
+    public void setName(Account account, String name) throws SQLException {
28
+        account.setName(name);
29
+        dao.update(account);
23 30
     }
24 31
 
25 32
     public int delete(Account account) throws SQLException {

+ 8
- 0
src/main/java/Console.java View File

@@ -20,5 +20,13 @@ public int intInput() {
20 20
     return scanner.nextInt();
21 21
 }
22 22
 
23
+public int prntTakeInt(String output) {
24
+    System.out.println(output);
25
+    return scanner.nextInt();
26
+}
23 27
 
28
+public String prntTakeStr(String output) {
29
+    System.out.println(output);
30
+    return scanner.nextLine();
31
+}
24 32
 }