@@ -104,7 +104,7 @@ public boolean hasStock(MapleStock ms, int quantity) {
104
104
if (pair .getLeft ().equalsIgnoreCase (ms .getTicker ())) amount += pair .getRight ();
105
105
if (amount >= quantity ) return true ;
106
106
}
107
- return false ;
107
+ return ( amount >= quantity ) ;
108
108
}
109
109
110
110
public boolean isEmpty () {
@@ -116,20 +116,20 @@ public void save() {
116
116
try {
117
117
Connection con = (Connection ) DatabaseConnection .getConnection ();
118
118
PreparedStatement ps ;
119
- if (!newlyAdded .contains (pair )) {
120
- ps = con .prepareStatement ("UPDATE maplestocks_data SET shares = ? WHERE cid = ? AND stockid = ?" );
121
- ps .setInt (1 , pair .getRight ());
122
- ps .setInt (2 , cid );
123
- ps .setInt (3 , MapleStocks .getInstance ().idOf (pair .getLeft ()));
124
- Output .print (ps .toString ());
125
- ps .executeUpdate ();
126
- } else {
119
+ if (newlyAdded .contains (pair )) {
127
120
ps = con .prepareStatement ("INSERT INTO maplestocks_data (`cid`, `stockid`, `shares`) VALUES (?, ?, ?)" );
128
121
ps .setInt (1 , cid );
129
122
ps .setInt (2 , MapleStocks .getInstance ().idOf (pair .getLeft ()));
130
123
ps .setInt (3 , pair .getRight ());
131
124
Output .print (ps .toString ());
132
125
ps .executeUpdate ();
126
+ } else {
127
+ ps = con .prepareStatement ("UPDATE maplestocks_data SET shares = ? WHERE cid = ? AND stockid = ?" );
128
+ ps .setInt (1 , pair .getRight ());
129
+ ps .setInt (2 , cid );
130
+ ps .setInt (3 , MapleStocks .getInstance ().idOf (pair .getLeft ()));
131
+ Output .print (ps .toString ());
132
+ ps .executeUpdate ();
133
133
}
134
134
} catch (SQLException e ) {
135
135
Output .print ("Something went wrong while saving a MapleStockPortfolio." );
0 commit comments