1. John Louis del Rosario
  2. expenses

Commits

John Louis del Rosario  committed d0178cd

Changes

  • Participants
  • Parent commits f3ee912
  • Branches default

Comments (0)

Files changed (1)

File ExpenseParser.pde

View file
  • Ignore whitespace
     parseCSVFile(lines);
   }
 
+  //get expenses of the date
+  public Expense[] getExpensesForDate(String date){
+    Date d;
+    ArrayList expensesForDate = new ArrayList();
+    d = parseDateString(date);
+    for(int i = 0; i < expenses.length; i++){
+      try{
+        if (expenses[i].date.equals(d)){
+          println(expenses[i]);
+          expensesForDate.add(expenses[i]);
+        }
+      }catch(NullPointerException e){
+        println(e.getMessage());
+        return null;
+      }
+    }
+    return expensesForDate;
+  }
+
+  public Expense[] getExpensesForDate(String date, HashMap filters){
+    return expenses;
+  }
+
+  //get expenses of date range
+  public Expense[] getExpensesForDateRange(String fromDate, String toDate){
+    return expenses;
+  }
+  public Expense[] getExpensesForDateRange(String fromDate, String toDate, HashMap filters){
+    return expenses;
+  }
+
+  private Date parseDateString(String date){
+    try{
+      return df.parse(date);
+    }catch(ParseException e){
+      return null;
+    }
+  }
   //parse CSV file and place its data into expenses array
-  public void parseCSVFile(String[] lines){
+  private void parseCSVFile(String[] lines){
     for (int i = 0; i < lines.length; i++){
       String[] pieces = splitLine(lines[i]);
       //[0] date, [1] type, [2] amount, [3] currency, [4] String paidWith, [5] String category, [6] String note, [7] String list
     }
   }
 
-  String[] splitLine(String line){
+  private String[] splitLine(String line){
     char[] c = line.toCharArray();
     ArrayList pieces = new ArrayList();
     int prev = 0;
     return outgoing;
   }
 
-  //get expenses of the date
-  public Expense[] getExpensesForDate(String date){
-    Date d;
-    try{
-      d = df.parse(date);
-    }catch(ParseException e){
-      return null;
-    }
-    for(int i = 0; i < expenses.length; i++){
-      try{
-        if (expenses[i].date.equals(d)){
-          println(expenses[i]);
-        }
-      }catch(NullPointerException e){
-        println(e.getMessage());
-      }
-    }
-    return expenses;
-  }
-  public Expense[] getExpensesForDate(String date, HashMap filters){
-    return expenses;
-  }
-
-  //get expenses of date range
-  public Expense[] getExpensesForDateRange(String fromDate, String toDate){
-    return expenses;
-  }
-  public Expense[] getExpensesForDateRange(String fromDate, String toDate, HashMap filters){
-    return expenses;
-  }
 }