Consider adding a doc comment for payOffDebt
94 return true;
95 }
96
97 public static boolean payOffDebt(String id, double amount) { 98 double deposit, debt; 99 String temp = SqlQuery.StringGetSQL("SELECT debt FROM clients WHERE id=" + id, "debt");100 debt = stringToDouble(temp);101 temp = SqlQuery.StringGetSQL("SELECT deposit FROM clients WHERE id=" + id, "deposit");102 deposit = stringToDouble(temp);103 if (amount > deposit) {104 System.out.println("Odemek istediginiz tutar bakiyenizden fazla olamaz. ");105 return false;106 } else if (amount > debt) {107108 deposit = deposit - debt;109 debt = 0;110 temp = String.valueOf(deposit);111 SqlQuery.UpdateData("UPDATE clients SET deposit=" + temp + "WHERE id=" + id);112 SqlQuery.UpdateData("UPDATE clients SET debt=0 WHERE id=" + id);113 System.out.println(114 "girdiginiz tutar borcunuzdan fazladir, borcunuz: " + debt + " TL ödenmistir. ");115 return true;116117 } else {118 deposit = deposit - amount;119 // todo: handle if temp is not a string120 temp = String.valueOf(deposit);121 SqlQuery.UpdateData("UPDATE clients SET deposit=" + temp + "WHERE id=" + id);122 debt = debt - amount;123 temp = String.valueOf(debt);124 SqlQuery.UpdateData("UPDATE clients SET debt=" + temp + "WHERE id=" + id);125 return true;126 }127 }128}
Consider adding a doc comment for transfer
63 return true;
64 }
65
66 public static boolean transfer(String id, String IBAN, double amount) { 67 // todo: iban uzunlugunun kontrol edilmesi gerekli 68 if (IBAN.length() != 24) return false; 69 70 double depositSender, depositReceiver; 71 String temp = SqlQuery.StringGetSQL("SELECT deposit FROM clients WHERE id=" + id, "deposit"); 72 depositSender = stringToDouble(temp); 73 depositSender = depositSender - amount; 74 if (amount < 1) { 75 System.out.println("Gondereceginiz tutar 0'dan buyuk olmalıdır. "); 76 return false; 77 } 78 if (depositSender < amount) { 79 System.out.println("Bakiye yetersiz. "); 80 return false; 81 } 82 temp = 83 SqlQuery.StringGetSQL( 84 "SELECT deposit FROM clients WHERE IBAN LIKE '%" + IBAN + "'", "deposit"); 85 depositReceiver = stringToDouble(temp); 86 87 depositReceiver = depositReceiver + amount; 88 89 temp = String.valueOf(depositReceiver); 90 SqlQuery.UpdateData("UPDATE clients SET deposit=" + temp + " WHERE IBAN LIKE '%" + IBAN + "'"); 91 92 temp = String.valueOf(depositSender); 93 SqlQuery.UpdateData("UPDATE clients SET deposit=" + temp + "WHERE id=" + id); 94 return true; 95 } 96
97 public static boolean payOffDebt(String id, double amount) {
98 double deposit, debt;
Consider adding a doc comment for deposit
45 return false;
46 }
47
48 public static boolean deposit(String id, double amount) { 49 double deposit; 50 51 String temp = SqlQuery.StringGetSQL("SELECT deposit FROM clients WHERE id=" + id, "deposit"); 52 if (amount < 1) { 53 System.out.println("yatiralacak tutar sifirdan kucuk olamaz"); 54 return false; 55 } 56 57 deposit = stringToDouble(temp); 58 59 deposit = deposit + amount; 60 temp = String.valueOf(deposit); 61 SqlQuery.UpdateData("UPDATE clients SET deposit=" + temp + "WHERE id=" + id); 62 63 return true; 64 } 65
66 public static boolean transfer(String id, String IBAN, double amount) {
67 // todo: iban uzunlugunun kontrol edilmesi gerekli
Consider adding a doc comment for withdraw
14 return val;
15 }
16
17 public static boolean withdraw(String id, double amount) { 18 double deposit; 19 if (amount < 10 || amount > 1000) { 20 System.out.println("cekilecek tutar 10'dan kucuk olamaz"); 21 return false; 22 } 23 24 String temp = SqlQuery.StringGetSQL("SELECT deposit FROM clients WHERE id=" + id, "deposit"); 25 26 try { 27 deposit = Double.parseDouble(temp); 28 System.out.println(deposit); 29 } catch (Exception e) { 30 e.printStackTrace(); 31 return false; 32 } 33 34 if (deposit < amount) { 35 System.out.println("cekilmek istenen tutar bakiyeden fazla.. "); 36 return false; 37 } else if (deposit > amount) { 38 deposit = deposit - amount; 39 temp = String.valueOf(deposit); 40 41 SqlQuery.UpdateData("UPDATE clients SET deposit=" + temp + "WHERE id=" + id); 42 43 return true; 44 } 45 return false; 46 } 47
48 public static boolean deposit(String id, double amount) {
49 double deposit;
Consider adding a doc comment for StringGetSQL
33 }
34 }
35
36 public static String StringGetSQL(String query, String label) {37 String temp = null;38 try {39 Class.forName("com.mysql.cj.jdbc.Driver");40 Connection con =41 DriverManager.getConnection("jdbc:mysql://localhost:3306/atm", "root", "root");42 Statement stmt = con.createStatement();43 ResultSet rs = stmt.executeQuery(query);44 while (rs.next()) {45 temp = rs.getString(label);46 }4748 } catch (Exception e) {49 e.printStackTrace();50 }51 return temp;52 }53}
Consider adding a doc comment for getResult
4import java.sql.Statement;
5
6public class SqlQuery {
7 public static ResultSet getResult(String query) { 8 9 try {10 Class.forName("com.mysql.cj.jdbc.Driver");11 Connection con =12 DriverManager.getConnection("jdbc:mysql://localhost:3306/atm", "root", "root");13 Statement stmt = con.createStatement();14 return stmt.executeQuery(query);1516 } catch (Exception e) {17 return null;18 }19 }20
21 // todo: fonksiyon bool veri döndürmeli
22 public static void UpdateData(String query) {
Description
This method does not have any documentation.
Consider adding a documentation comment to explain its use.
While it may seem like the usage of a method is perfectly obvious, any consumers of your API may not be able to pick up on certain details.
Bad Practice
This method appears to return an address string based on its name and the return type, but it is hard to say anything further about it. We neither know if the address will be formatted in a special way nor are we given any useful information regarding the returned value.
String getAddress() {
// ...
}
Recommended
Provide a detailed description of what the method does.
/**
* Returns the address in 3 line format,
* with street address on line 1, area/city on line 2
* and state and country as well as postal code on line 3.
*/
String getAddress() {
// ...
}